Did you know that you can use Publitio to perform URL-based transformations and perform on-the-fly transcoding? Yeah! Publitio offers a URL-based form of API through which you can do all file transformations by changing parameters in the file URL.


What is a transformation, anyways? A transformation (when it comes to Publitio) is instructions on how to change a media file in some way. To put it simply, it’s converting files from one format to another, making resolution and quality changes, cropping, trimming, watermarking files, etc.



Before we discuss which transformations we can do with Publitio, we need to know what we can use for transforming our files:

  1. w and h for resizing

  2. c for cropping

  3. wm for watermarking

  4. q for quality

  5. t/so for/eo for trimming


And these are file types you can upload to Publitio:


  1. Video: mp4, webm, ogv, avi, mov, flv, 3gp, 3g2, wmv, mpeg and mkv

  2. Image: jpg, jpeg, jpe, png, gif, BMP, PSD, webp, ai, tif, tiff, SVG and ico

  3. Audio: mp3, wav, ogg, aac, aiff, amr, ac3, au, flac, m4a, aac, ra, voc and wma 

  4. Document: pdf


  1. Resizing


Responsive design and art direction generally require displaying images and videos at a variety of sizes, often much smaller than the original.

To resize image or video to 400px in width append w400 to the URL as in:

https://media.publit.io/file/w_400/PublitioImage.png



You can also resize the video 400x400px in size. To resize video 400x400px you need to append w_400 and h_400 to the URL like in the example below:

https://media.publit.io/file/w_400,h_400/PublitioImage.png 



  1. Cropping


If you want to crop an image you need to use the c parameter in combination with w (width) and h(height) parameters. 


For cropping, please use the c parameter in combination with w (width) and h (height) parameters. Supported values are c_fit (fit), c_fill (fill) and c_limit (limit).


c_fill will resize the image or video to the exact given width and height while retaining the original aspect ratio, using only a part of the original file that fills the given dimensions if necessary.


To create a 300x300 pixel thumbnail out of an image with c_fill, append w_300,h_300,c_fill to the URL as in:

https://media.publit.io/file/w_300,h_300,c_fill/PublitioImage.png 



c_fit will resize the file so that it takes up as much space as possible within a bounding box defined by the given width and height parameters. 

The original aspect ratio is retained and all of the original files are visible. 

To create 300x300 pixel thumbnail out of our sample image with c_fit, append w_300,h_300,c_fit to the URL as in:

https://media.publit.io/file/w_300,h_300,c_fit/PublitioImage.png 



c_limit is the same as the c_fit mode but only if the original file is larger than the given limit (width and height), in which case the image or video is scaled down so that it takes up as much space as possible within a bounding box defined by the given width and height parameters.


  1. Watermarking


For watermarking, videos and images use the wm option. 

Example: To watermark an image, we use a watermark with id lgo1 append  wm_lgo1 to the URL

https://media.publit.io/file/wm_lgo1,w_800/PublitioImage.png 



  1. Quality


With Publitio using transformation you can also control the quality of your images, video, and audio files. Using q parameters you can reduce or increase the quality of images.

Example: If you want to reduce the quality of the image, you need to use q_50

https://media.publit.io/file/q_50/PublitioImage.png 



  1. Trimming


For trimming (you can use this on video and audio files) please use the parameter so (start offset) and parameter eo (end offset).

Option t (time) can be used for video to image transformation. For example, to get an image from the 3rd second of the video, use t_3 as an option and set the extension to jpg in the URL:https://media.publit.io/file/t_3,w_800/PublitioTutorials/Publitio-Watermarking-Images.jpg 



To create a 2-second long trimmed video out of the original video starting from the 2nd second, use so_2,eo_2 in the URL. so_2 indicates from which second (2) to start trimming and eo_2 is making the trimmed video 2 seconds long, like in the example URL below:

https://media.publit.io/file/so_2,eo_2,h_480/PublitioTutorials/Publitio-Watermarking-Images.mp4 



To create a 2 second long trimmed audio from original audio starting at 1st second, use so_1,eo_2 in the URL. so_1 indicates at which second (1) to start trimming and eo_2 makes the trimmed audio 2 seconds long:

https://media.publit.io/file/so_1,eo_2/railgun.mp3 


It is possible to transform image into video, image to image, video to video, video to image, video to audio, audio to audio, audio to image, audio to video with URL Based API. 


  1. Transcoding


Image to image


You can transcode images to jpeg, jpe, png, gif, BMP, PSD, webp, ai, tif, tiff, SVG and ico format. You just need to change the extension in the URL.

Example: https://media.publit.io/file/PublitioImage.webp 



Image to video


To create an mp4 video out of an image (useful for gif files and player integration), change the extension to mp4:

https://media.publit.io/file/PublitioImage.mp4 




Video to video


Any video you upload can be transcoded to mp4, webm, and ogv formats.

To create 360p mp4 video out to original video, you need to format video URL like this:

https://media.publit.io/file/h_360/earth-zoom-in_cPsAwsOL_vlwx-p.mp4




Video to image


You can extract an image from any part of the video. To create a jpg image from the 4th second of the video, you need to add t_4 to the URL:

example: https://media.publit.io/file/t_4/earth-zoom-in_cPsAwsOL_vlwx-p.jpg 






Video to audio


Any video you upload can be transcoded to mp3, wav or ogg audio formats.

To create mp3 audio out of the video, just format URL as in:

Example: 

https://media.publit.io/file/PublitioTutorials/Publitio-Watermarking-Images.mp3 



Audio to audio


Any audio you upload can be transcoded to the following audio formats like mp3. wav or ogg.

To create wav audio out of original mp3 audio (https://media.publit.io/file/railgun.mp3 ), you need to format URL like the one below:

https://media.publit.io/file/railgun.wav 



Audio to video


You can create videos out of audio files.

Supported video from audio formats are mp4, webm and ogv. 

To create an mp4 video out of our original wav audio, format the URL like this one:

https://media.publit.io/file/railgun.mp4 




Now that you’re thoroughly acquainted with all of the options Publitio offers, there's nothing stopping you from using Publitio to get all the desired results that you always needed but maybe weren’t sure how. And all of that easily and quickly.


Want to know more? Visit the Publitio documentation page to learn about all the possible options.