Image optimization use cases

This page provides examples for advanced image processing behavior, pipeline ordering effects, and automatic image normalization rules.

Order of transformations

Operations in the imop query parameter string run in a structured execution pipeline:

  1. Freeze and Scale:

    • If Scale is specified, it must be the first operation in the query string.
    • If Freeze is specified on an animated GIF, frame extraction occurs before any subsequent geometric transformations.
  2. Geometric and visual filter operations (Crop, Rotate, Mirror, Resize, Blur, Tone, and Sharpen):

    • These operations are executed sequentially from left to right in the exact order they appear in the query parameter string.
    • Because each operation acts directly on the visual output of the preceding operation, the sequence of your parameters affects the final visual output.
  3. Output encoding operations (Convert, Compress, Quality, Metadata):

    • Format conversion, compression or numeric quality adjustment, and metadata preservation, including C2PA Content Credentials manifests, are applied during final output encoding.
  4. Canvas:

    • If Canvas is specified, it must be the last operation in the query string and is always applied last.

Consider a source image that is 1,000 pixels wide by 1,000 pixels high:

Example: Resize then Crop

https://www.example.com/image.jpg?imop=Resize,width=200;Crop,left=0.5

  1. Resize: The original 1000×1000 px image is resized to 200×200 px (preserving the 1:1 aspect ratio).

  2. Crop: the left=0.5 operation crops out the left half of the already-resized image.

Result: A 100 x 200 px image representing the right 50% of the content.

Example : Crop then Resize

https://www.example.com/image.jpg?imop=Crop,left=0.5;Resize,width=200

  1. Crop: The left=0.5operation extracts the right 50% of the high-resolution source image first, creating a 500 x 1000 px intermediate image (changing the aspect ratio to 1:2).

  2. Resize: The width=200 parameter resizes this intermediate image. To preserve the new 1:2 aspect ratio, the height scales to 400 px.

Result: A 200 * 400 px final image.

Stretch and upscaling behavior

By default, the image optimization service enforces a strict, downscale-only strategy to conserve edge delivery bandwidth and protect visual quality. If you request dimensions larger than the original image without an upscaling parameter, Cloud CDN outputs the image at its original dimensions.

To override this behavior and upscale an image, specify the scaling attribute in the Resize operation:

  • scaling=proportional: Enables upscaling while preserving the original aspect ratio.
  • scaling=stretch: Forces the image to upscale to the exact requested dimensions, ignoring the original aspect ratio.

Validation requirements for stretch upscaling:

  • Dual sizing rule: The stretch value is permitted only if you explicitly provide both the width and height parameters in the Resize operation.

  • Single dimension constraint: If you specify scaling=stretch while defining only a single dimension, such as width or height, Cloud CDN rejects the request with an HTTP 400 Bad Request status code.

For example:

  • Valid proportional upscale: ?imop=Resize,width=1200,scaling=proportional
  • Valid stretch upscale: ?imop=Resize,width=1200,height=800,scaling=stretch
  • Invalid stretch request: ?imop=Resize,width=1200,scaling=stretch (rejected with HTTP 400)

C2PA Content Credentials preservation

Cloud CDN image optimization supports the Coalition for Content Provenance and Authenticity (C2PA) standard (Content Credentials) to preserve cryptographic provenance across dynamic edge transformations.

When an origin image contains a valid C2PA manifest and undergoes edge optimization, the following process occurs:

  1. Cloud CDN validates the incoming C2PA manifest on the origin image.

  2. Unless you specify the Metadata,preserve=none parameter, the edge optimization engine records the applied transformations, such as resizing, cropping, or format conversion, as digital edits in the manifest. The engine then cryptographically re-signs the derivative image by using a Google-managed C2PA signing certificate.

  3. If an origin image does not contain a C2PA manifest, Cloud CDN doesn't attach a new manifest.

Metadata parameter settings for C2PA

Metadata parameter Standard metadata (EXIF / IPTC / XMP) C2PA Content Credentials manifest
Default (no Metadata operation) or Metadata,preserve=copyright Preserves only Author, Copyright, and Caption Preserved and updated with applied edge transformations
Metadata,preserve=c2pa Stripped Preserved and updated with applied edge transformations
Metadata,preserve=max Preserves all metadata, except EXIF orientation and ICC color profiles baked into pixels Preserved and updated with applied edge transformations
Metadata,preserve=none Stripped Stripped

C2PA cache TTL guidance (< 30 days)

For performance at the edge, dynamically generated C2PA manifests are signed without an external Trusted Timestamp Authority (TSA) token. C2PA validators verify the manifest against the validity period of the signing certificate itself, which typically rotates every 30 days to 6-12 months.

Recommendation: If your application relies on C2PA Content Credentials validation, configure your Cloud CDN cache policy TTL (defaultTtl, clientTtl, and maxTtl) or origin Cache-Control: max-age to less than 30 days (< 2,592,000 seconds). This helps ensure cached image variants are periodically refreshed and re-signed with an active certificate before expiration.

Normalization in Cloud Logging

Due to internal performance and cache-key normalization optimizations, the order of operations and attributes recorded in the transformationList field in Cloud Logging might differ from the order in the client request URL:

  • Attributes within each operation are normalized in alphabetical order. For example, they might appear as resize,height=125,width=250.
  • Operations are grouped into the canonical pipeline order: Freeze, followed by geometric and visual filters, Convert, Compress or Quality, Metadata, and Canvas.

This normalization maximizes cache hit ratios without altering the visual output of your transformations.

Caching and cache invalidation

When you update an original image on your origin server, you must invalidate the cached version to ensure Cloud CDN retrieves and serves the updated asset.

Caching behavior

Every unique combination of transformation parameters appended to an image URL creates a separate, distinct cache entry at the edge. To optimize your cache-hit ratio, avoid creating excessive numbers of unique parameter variations. For example, single-pixel changes.

Cloud CDN normalizes cache keys to group identical transformation parameters regardless of their order in the query string.

Invalidation behavior

When you update an original image on your origin server, you only need to submit a single invalidation request for the base image URL. The enhanced Cloud CDN automatically purges both the cached original image and all of its automatically generated variants (such as WebP or optimized versions) globally.

How Variant Invalidation Works

When you issue a cache invalidation request using a path pattern that matches a base image URL, for example,/images/my-picture.jpg, Cloud CDN automatically identifies and purges:

  • The original cached source image.

  • All of its previously generated variants

You can apply Cloud CDN cache invalidation using:

  • Google Google Cloud console: navigate to Network Services > Cloud CDN, select the origin, and go to the Cache Invalidation tab. Alternatively, go to Network Services > Load Balancing, select your load balancer, and use the Cache Invalidation tab.

  • Google Cloud CLI: use the Google Cloud CLI compute url-maps invalidate-cdn-cache command.

  • Cache Tags : Cache tags is the recommended approach for managing optimized images. This lets you issue invalidation requests targeting a specific tag, which purges the content associated with it for more granular control.

For example:

To invalidate /images/my-picture.jpg and all of its optimized variants globally:

  • Path: specify the exact path /images/my-picture.jpg.

  • Host (Optional): specify the host if you only want to clear the image for a specific domain.

When submitted, this single action removes all optimized versions of the image from edge caches globally, ensuring users immediately receive the updated version on their next request.

Color profile and image orientation in EXIF (normalization)

Modern smartphones and digital cameras frequently save images with raw, unrotated pixel grids and rely on an embedded EXIF orientation tag to to instruct the viewing device to rotate the image. For example, 90 degrees clockwise for portrait orientation. Similarly, embedded ICC color profiles define how colors display across different monitors.

To help ensure predictable operations, the image optimization edge pipeline automatically normalizes images before running any transformations.

Normalization process

  • Prior to executing transformations, the edge engine reads EXIF orientation tags and ICC color profile metadata and physically applies them to the pixel grid. This helps ensure coordinate predictability for subsequent crop and resize operations.

  • Operations, such as crop, resize or scale execute correctly against the true visual dimensions to prevent visual errors.

  • After applying adjustments to the core pixels, the edge engine removes all non-essential metadata from the file to maximize size savings. By default, it retains copyright unless a specific value is requested in metadata operation.

What's next