> ## Documentation Index
> Fetch the complete documentation index at: https://gcore-doc-1894.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# About Image Stack

Image Stack is a paid CDN option that optimizes JPG and PNG images on the fly. Original images remain unchanged on the origin; CDN serves transformed versions from cache. Image Stack includes four operations:

* [Quality](/cdn/cdn-resource-options/image-optimization-paid/image-stack-tools/change-image-quality) — sets the quality level for images. Lowering the quality value also reduces file size, so images reach users faster.
* [Compression](/cdn/cdn-resource-options/image-optimization-paid/image-stack-tools/configure-image-compression-to-webp-and-avif) — converts images to WebP and AVIF formats, providing up to 55% file size savings at a given quality level.
* [Resize](/cdn/cdn-resource-options/image-optimization-paid/image-stack-tools/reduce-image-size) — reduces the height, width, and scale of the original image.
* [Crop](/cdn/cdn-resource-options/image-optimization-paid/image-stack-tools/crop-images) — removes unwanted image area beyond the specified dimensions.

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/D4afn3gx_zp92kAa/images/docs/cdn/cdn-resource-options/image-optimization-paid/about-image-stack/about-image-stack-image1.png?fit=max&auto=format&n=D4afn3gx_zp92kAa&q=85&s=e0293f310e73570a57a1e912416ad2f8" alt="Image Stack toggle under Optimization in CDN resource settings" width="70%" data-path="images/docs/cdn/cdn-resource-options/image-optimization-paid/about-image-stack/about-image-stack-image1.png" />
</Frame>

How Image Stack transforms an image:

<Tabs>
  <Tab title="Original image">
    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1894/D4afn3gx_zp92kAa/images/docs/cdn/cdn-resource-options/image-optimization-paid/about-image-stack/11758218361745.png?fit=max&auto=format&n=D4afn3gx_zp92kAa&q=85&s=bc182480177f247e68ec009d72affe6e" alt="Original image sample — 553x743 px, 3.55 MB JPEG" width="70%" data-path="images/docs/cdn/cdn-resource-options/image-optimization-paid/about-image-stack/11758218361745.png" />
    </Frame>

    * Format: jpg
    * Quality: 100%
    * Size: 3.55 MB
    * W×H: 553×743 px
  </Tab>

  <Tab title="Compression">
    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1894/D4afn3gx_zp92kAa/images/docs/cdn/cdn-resource-options/image-optimization-paid/about-image-stack/11758218290321.png?fit=max&auto=format&n=D4afn3gx_zp92kAa&q=85&s=9d63ba68c5a24fd55959eb47e70d43f2" alt="Same image after AVIF compression — 476 KB" width="70%" data-path="images/docs/cdn/cdn-resource-options/image-optimization-paid/about-image-stack/11758218290321.png" />
    </Frame>

    * Format: avif
    * Quality: 95%
    * Size: 476 KB
  </Tab>

  <Tab title="Quality">
    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1894/D4afn3gx_zp92kAa/images/docs/cdn/cdn-resource-options/image-optimization-paid/about-image-stack/11758218279441.png?fit=max&auto=format&n=D4afn3gx_zp92kAa&q=85&s=18f676502af8097d8bf42da7567c18a3" alt="Same image at 10% quality — 8 KB AVIF" width="70%" data-path="images/docs/cdn/cdn-resource-options/image-optimization-paid/about-image-stack/11758218279441.png" />
    </Frame>

    * Quality: 10%
    * Format: avif
    * Size: 8 KB
  </Tab>

  <Tab title="Resize">
    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1894/D4afn3gx_zp92kAa/images/docs/cdn/cdn-resource-options/image-optimization-paid/about-image-stack/11758218201233.png?fit=max&auto=format&n=D4afn3gx_zp92kAa&q=85&s=49b185a960a40e82c747163f18a14273" alt="Same image resized to 333x500 px" width="70%" data-path="images/docs/cdn/cdn-resource-options/image-optimization-paid/about-image-stack/11758218201233.png" />
    </Frame>

    * W×H: 333×500 px
  </Tab>

  <Tab title="Crop">
    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1894/D4afn3gx_zp92kAa/images/docs/cdn/cdn-resource-options/image-optimization-paid/about-image-stack/11758218206481.png?fit=max&auto=format&n=D4afn3gx_zp92kAa&q=85&s=117a761176f7bf72c6a7d526a6723294" alt="Same image cropped to 400x500 px from center" width="70%" data-path="images/docs/cdn/cdn-resource-options/image-optimization-paid/about-image-stack/11758218206481.png" />
    </Frame>

    * W×H: 400×500 px — segment from the center
  </Tab>
</Tabs>

## Processing pipeline

When Image Stack is enabled on a CDN resource, requests for images are routed through the Image Processor. The Image Processor fetches the original image from the origin, applies the configured transformations, and stores the processed version in the CDN cache.

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/D4afn3gx_zp92kAa/images/docs/cdn/cdn-resource-options/image-optimization-paid/about-image-stack/11756318311697.png?fit=max&auto=format&n=D4afn3gx_zp92kAa&q=85&s=38183a3cf5286099cfa41d1e7d526af2" alt="Image Stack flow: origin to Image Processor to CDN cache to user browser" width="70%" data-path="images/docs/cdn/cdn-resource-options/image-optimization-paid/about-image-stack/11756318311697.png" />
</Frame>

After processing, image URLs and file extensions remain unchanged. The following HTTP headers are added to the response to track transformation details:

* **X-Img-Operations** — operations performed
* **X-Img-Origin-Download-Time** — time to download the image from the origin, in milliseconds
* **X-Img-Origin-Size** — original image size in bytes
* **X-Img-Processing-Time** — time taken to transform the image, in milliseconds
* **X-Img-Saved-Bytes** — how many bytes the image size decreased after processing
* **X-Img-Server** — the server that processed the image
* **Img-Skip-Reason** — the reason an operation was not performed

Image transformation operations are applied in this order, because resizing and cropping reduce the image to its final dimensions before format conversion — this avoids compressing pixels that are later discarded:

1. Resizing
2. Cropping
3. Compression to WebP or AVIF, with quality adjustment

<Note>
  The Quality operation cannot run independently. Enable at least one other operation — Compression, Resize, or Crop — alongside Quality.
</Note>

## Processing limitations

If an image cannot be processed, CDN serves the original image from the origin. The following conditions prevent Image Stack from processing an image:

* **Original quality is lower than the target quality.** If the original image quality is 45 and the target is 80, processing would increase the file size rather than decrease it.
* **Gzip compression is applied to the original image.** If the image contains the `Content-Encoding: gzip` header, Image Stack cannot unzip the original.
* **The browser does not support the target format.** If the request does not advertise support for `image/webp` or `image/avif`, Image Stack does not convert the image to the corresponding format.
* **Unsupported image format.** Image Stack processes only JPG and PNG files. GIF and other formats are served as-is.

Use the `Img-Skip-Reason` response header to identify why an image was not transformed.

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/D4afn3gx_zp92kAa/images/docs/cdn/cdn-resource-options/image-optimization-paid/about-image-stack/11085759743505.png?fit=max&auto=format&n=D4afn3gx_zp92kAa&q=85&s=2ce7ee36dda4db3894ab373f113e5d39" alt="Browser DevTools response headers showing img-skip-reason with unsupported content type reason" width="70%" data-path="images/docs/cdn/cdn-resource-options/image-optimization-paid/about-image-stack/11085759743505.png" />
</Frame>

## Conflict with the Rewrite option

Google Chrome and other browsers add the `Accept: image/webp, image/avif` header to all requests — including requests for static files like PHP and JS scripts, not only images. When Image Stack is enabled for the entire resource, those requests are routed to the Image Processor.

The conflict occurs when the [Rewrite](/cdn/cdn-resource-options/rewrite-redirect-requests-from-the-cdn-to-the-origin) option is also active. The Rewrite option redirects requests to the origin, which responds with a `3xx` code. The Image Processor cannot return `3xx` responses to clients — it follows the redirect in a loop until receiving a non-3xx response, making PHP and JS files inaccessible.

To avoid this, configure Image Stack as a rule scoped to `image/jpeg` and `image/png` MIME types rather than enabling it for the entire resource. The [Enable Image Stack](/cdn/cdn-resource-options/image-optimization-paid/enable-image-stack) article covers the rules configuration.

Enable Image Stack for the entire resource in Resource Settings only when the origin consists entirely of static image assets.
