Skip to main content
Compression converts JPG and PNG images to WebP or AVIF format during CDN delivery, reducing file size without visible quality loss. WebP and AVIF use advanced compression algorithms — the painting by Wassily Kandinsky below demonstrates: sharpness and color rendering are the same across formats, but the WebP and AVIF files are smaller. To apply compression, configure it in the Gcore Customer Portal or add the fmt query string to individual image URLs.
PNG example

Enable compression

Compression is part of the paid Image Stack option, which also supports resizing, cropping, and quality adjustment. Before enabling compression, activate Image Stack — Enable Image Stack.

Use compression

Two methods are available: the Gcore Customer Portal and query strings. The portal method applies compression to all images matching the rule’s URL pattern. The query string method applies compression per individual image URL.

Use compression in the customer portal

1. Navigate to Rules in the CDN resource and open the Image optimization rule.
Rules list showing the Image optimization rule
2. Select Enable WebP compression and/or Enable AVIF compression. When both are enabled, the format is chosen based on browser support — browsers that support both receive AVIF.
Image Stack settings with Enable WebP compression and Enable AVIF compression checkboxes
3. Click Save changes at the top right of the page. Images are served in WebP or AVIF format to supported browsers.

Use compression via query parameters

1. Open the website source code. 2. Find the URLs of the images to convert. 3. Add a query string to each image URL:
where value is one of:
  • webp — converts to WebP format
  • avif — converts to AVIF format
  • avif,webp — converts to WebP or AVIF based on browser support: image.jpg?fmt=avif,webp
4. Save the changes. Images are served in the configured format.

Check HTTP headers

After converting, an image does not change its URL or extension. Use the HTTP response headers to verify the conversion. The X-Img-Operations header reflects all the conversions performed. If the value includes convert, the image format has been converted. The Content-Type header shows the compression format. The value image/webp or image/avif confirms the image is in the new format.
X-Img-Operations and Content-Type headers in a CDN response showing successful WebP conversion
If the X-Img-Operations header contains no convert value and the CDN returns the image with original quality, inspect the Img-Skip-Reason HTTP header for the skip reason. The value converted image bigger than origin value means the configured quality exceeds the source image quality — lower the quality setting in Change image quality.
Img-Skip-Reason header showing why the image conversion was skipped