Skip to content

Image Transformation

storage images resize transform optimization webp avif thumbnails

Images can be transformed on-the-fly by adding query parameters to file URLs. Transformations work with both public URLs and pre-signed URLs, and results are cached at the CDN layer.

ParameterDescriptionValues
wMaximum width (maintains aspect ratio)Pixels (e.g., 400)
hMaximum height (maintains aspect ratio)Pixels (e.g., 300)
qImage quality1100 (applies to JPEG, WebP, PNG)
fOutput formatauto, same, jpeg, webp, png, avif
bBlur sigma0 or higher

Format options:

  • auto — uses content negotiation based on the Accept header (serves WebP/AVIF to browsers that support it)
  • same — keeps the original format (default)
// Fetch a 100x100 WebP thumbnail
const { body } = await nhost.storage.getFile(fileId, {
w: 100,
h: 100,
f: 'webp',
})
const url = URL.createObjectURL(body)

Transformed images are cached at the CDN level. The first request for a specific combination of parameters generates the transformed image; subsequent requests are served from cache.

Each unique set of query parameters is treated as a separate cached resource. Keep the number of distinct parameter combinations reasonable to maximize cache hit rates. See CDN for more details.