I have images in different formats like JPG and PNG. I want to convert them to WebP so that they load quickly at a smaller size? Is there a way to convert the images to WebP automatically or one at a time?
If you have JPG or PNG images and want to convert them to WebP for faster loading and reduced file size, ImageKit offers an easy solution. Whether your files are in the ImageKit Media Library or stored on a connected External storage, ImageKit lets you deliver WebP images either automatically or by setting the format manually.
Automatic Format Conversion
ImageKit automatically selects the best image format for each user by analyzing factors such as device capabilities, browser support, and your preferences. It ensures that images are delivered in the most optimal format.
To use this feature, enable the “Use best format for image delivery” setting in your ImageKit dashboard under the image settings.
Alternatively, you can use the URL-based transformation parameter f-auto
to optimize individual images dynamically. This works similarly to the global setting but allows you to apply the transformation per image rather than system-wide.
Example URL:
https://ik.imagekit.io/ikmedia/example_image.jpg?tr=f-auto
Note: In this case, if the original image is in JPEG format and the requesting browser supports WebP, this feature will automatically deliver the image in WebP format.
Forcing an Output Format
If you prefer to specify the output image format, ImageKit allows you to do so using URL-based transformation parameters.
How to Force a Specific Format
By using the format f
parameter to your image URL, you can convert an image to a preferred format. This ensures consistent delivery in the desired format, regardless of the user’s browser or device.
Example: Convert a JPEG image to WebP
- Original JPEG Image:
https://ik.imagekit.io/ikmedia/example_image.jpg
- WebP Output Using ImageKit:
https://ik.imagekit.io/ikmedia/example_image.jpg?tr=f-webp
Note: Use the transformation parameter f-webp
to explicitly serve your images in WebP format.