How to resize a JPEG image?

Can you share examples of how to resize a JPEG image with ImageKit? Can I do it if my file is stored in my own cloud storage or do I have to first upload it your Media Library and then there is an option to resize the JPEG image?

Resizing a JPEG image using URL-based resizing parameters

ImageKit provides real-time, URL-based resizing parameters for all images, whether you upload them to the ImageKit Media Library or store them on your server or cloud storage that is connected to ImageKit.

You simply need to add the height or width in the URL and get the output image resized. You can directly use this URL on your website or app and it will load quickly, no need to download or save this image again.

For example, the original JPG below is 2000x1333 px.

https://ik.imagekit.io/ikmedia/example_image.jpg

We can resize it to width 400px by adding ?tr=w-400 to the URL

https://ik.imagekit.io/ikmedia/example_image.jpg?tr=w-400

Similarly, you can resize it to height 300px by adding ?tr=h-300 instead.

You can specify either height or width or combine one of these parameters with the aspect ratio parameter to resize the JPEG image in real time.

For example, a 300px wide image with 1:1 aspect ratio will be

https://ik.imagekit.io/ikmedia/example_image.jpg?tr=w-300,ar-1-1

This URL gets delivered via a CDN for fast loading time, and you can directly use it on your website or app.

Manual resize

You can also resize this image manually if needed. Upload the image to the ImageKit media library, which is a built-in DAM solution, and use the image editor to resize the image. You can then download or save the image to the media library by clicking on “Export” in the editor.