Automatic Best Image Format Selection

Manu Chaudhary

Given multiple image formats to choose from, it often becomes difficult for developers to make sure that images on their website and app are in the correct format. Among other image optimization techniques, this is one of the very important ones.

What is right image format?

The right format for a particular image depends on the content of that image, and available format support in the requesting browser (or device).

For example:

Example 1

WebP image format

WebP 21.6KB
JPG image format

JPG 24.3KB
PNG image format

PNG 47.1KB
Automatic Best Image Format Selection

No format specified

WebP – Use parameter f-webp. It won’t render in non-supporting browsers like Safari, FireFox, and IE.,f-webp/medium_cafe_B1iTdD0C.jpg

JPG – Use parameter f-jpg,f-jpg/medium_cafe_B1iTdD0C.jpg

PNG – Use parameter f-png,f-png/medium_cafe_B1iTdD0C.jpg

ImageKit automatic best image format selection

When you don’t specify any format parameter, i.e, f-png or f-jpg like below, then ImageKit chooses the best possible image format depending upon browser support and image content.

Example 2: Format selection based upon image content

WebP image format

WebP 6KB
PNG image format selection

image format selection automatically

best image format selection automatically

No format specified

This image has transparency layer, and JPG doesn’t support transparency, so the only two possible candidates are PNG and WebP. Although WebP offers much better compression, but in this particular case, the smallest image is PNG. With ImageKit automatic image format selection, a PNG is served when you don’t specify any format.

This automatic format selection works out of the box. You don’t have to add or change anything to your image URL. However, if you want to turn it off, you can do so with your ImageKit dashboard settings.

Automatic best image selection setting in ImageKit dashboard

Automatic best image selection setting in ImageKit dashboard

Let’s wrap it up!

So now you know that no single image format is “correct”. It largely depends upon the content of image and browser support. You can use this knowledge and improve your in-house image management software or try out ImageKit for free and automate this!