Transformations Overview

Transform images on the fly using URL query parameters.

Tuzzle transforms images on delivery by appending query parameters to the CDN URL. No pre-processing needed.

https://cdn.tzzl.io/{space}/{file}?w=400&h=300&f=webp&q=80&r=fit&g=center

Query Parameters

ParameterNameValuesDefault
wWidthPixels (integer)Original width
hHeightPixels (integer)Original height
rResize modescale, fit, fill, crop, thumbfit
gGravitycenter, north, south, east, west, northeast, northwest, southeast, southwest, face, faces, eyes, autocenter
fFormatjpeg, png, webp, avif, tiff, gif, pdfAuto-negotiated
qQuality1-100Dynamic based on size

How It Works

  1. A request hits the CDN with transformation parameters
  2. The CDN checks for a cached version
  3. If cached, the variant is served immediately
  4. If not cached, the CDN fetches the original, applies transformations, caches the result, and returns it
  5. Subsequent identical requests are served from cache

Auto-Format Negotiation

When no f parameter is specified, Tuzzle reads the Accept header and selects the best format:

  • If the client supports AVIF, serves AVIF
  • Otherwise if WebP is supported, serves WebP
  • Falls back to the original format

Dynamic Quality

When q is not specified, quality is automatically selected based on the output image dimensions:

Largest DimensionQuality
Up to 1000px90
1000-2500px85
2500-5000px80
5000-7500px75
7500-10000px70
Over 10000px60

Two-Phase Validation

Transformations are validated in two phases:

  1. Pre-meta validation: Checks parameter formats before fetching the image (e.g., valid numbers, valid resize mode)
  2. Post-meta validation: Checks parameters against the actual image metadata (e.g., crop dimensions require both width and height, format pixel limits)

Validation errors return a 422 status with details in the x-tzzl-errors response header. Non-blocking warnings are returned in x-tzzl-warnings.

Response Headers

Transformed responses include these custom headers:

HeaderDescription
x-image-widthOriginal image width
x-image-heightOriginal image height
x-blurhashBlurhash placeholder string
x-tzzl-warningsJSON array of transformation warnings
x-tzzl-errorsJSON array of validation errors (on 422)
cache-controlpublic, max-age=2592000 (30 days)