genko.meDocs
Publishing and integrations

Image transformation

Resize, format, and quality options for image URLs, and when an image isn't transformed.

Add a query to a media image URL to resize it, convert its format, or adjust its quality. You don't need to reprocess the original file in the dashboard. Get the URL from the dashboard or the delivery API.

Match the display size

You can build the URL with the SDK's buildImageUrl. This example assumes blog has an image field eyecatch.

ts
import { buildImageUrl } from "@genko-me/sdk";import { genko } from "@/lib/client";
const post = await genko.apis.blog.getOrNull("abcDEF123456");const imageUrl = post?.eyecatch?.url  ? buildImageUrl(post.eyecatch.url, { w: 800, format: "webp", q: 80 })  : null;

This function only builds the URL. It doesn't fetch the image. Pass the result to an img or similar on the display side. If the image field isn't defined, add it first and sync types with pull.

Parameters

NameValueIf omitted
wInteger from 1 to 2,000. Width in pxNot set
hInteger from 1 to 2,000. Height in pxNot set
qInteger from 1 to 100. Output quality80
formatwebp, avif, jpeg, png, autoKeep the original format
fitcover, contain, insidecover if both width and height are set, otherwise inside

q applies to WebP, AVIF, and JPEG, and not to PNG. An integer out of range or an unknown value returns 400. buildImageUrl validates values too, and throws when building the URL if a value is invalid.

Settings by use

UseExampleResult
Images in body textw=800Adjusts the width and keeps the ratio
List thumbnailsw=640&h=360&fit=coverFills the given frame and crops what overflows
Fit the whole image in a framew=640&h=360&fit=containKeeps the whole image, and adds margins if the ratios differ
Shrink to fit within a framew=640&h=360&fit=insideKeeps the ratio, and the output can be smaller than the frame

Images are never enlarged beyond the original. The width and height you set aren't always the actual output size.

format=auto

If the Accept header includes image/webp, the image is served as WebP, and otherwise in its original format. It doesn't pick AVIF automatically. If you need AVIF, set format=avif.

A response that was actually converted by the automatic format carries Vary: Accept. This differs from when the original file is returned without conversion.

When an image isn't transformed

  • With no transformation parameters, the original file is returned.
  • If the original file is larger than 25 MB, the original file is returned.
  • For an animated image, omitting format returns the original file. If you set a format, only the first frame is converted.

The size you can upload and the size that can be transformed are different. An image that uploaded successfully isn't transformed if it's over 25 MB.

If you add transformation settings to a file other than JPEG, PNG, WebP, GIF, or AVIF, you get 415. Don't add transformation parameters when serving PDFs and similar files.

Caching and replacement

Responses are served with Cache-Control: public, max-age=31536000, immutable. This lets browsers and others keep the same URL for a long time.

When you replace media, fetch the new URL from the delivery API. Don't assume the content at the same URL changes right away. Image URLs themselves can be fetched without an API key, so see Manage media for who can see them.

When it doesn't work as expected

For 400, check the values you set. For 415, check the format. If nothing is transformed, check the 25 MB limit and the animation rules. If the image stays small, check the original image's dimensions. Transformation times out after 20 seconds, including time in the queue, and returns 504 with the message Image transformation timed out.

Last updated: October 7, 2026

On this page