All docs pages
Docs

Image resizing

Thumbnails and lighter formats of uploaded photos, made on request.

In stackly.json and the CLI it is image-resizing. Its use, live or draft, is counted as image resizes; see Live app prices.

image-resizing · optional · needs backend, storage · Cloudflare Images

Thumbnails and lighter formats of images the app keeps in storage, made on the first request and kept for the next.

Turn it on

"features": ["backend", "storage", "image-resizing"],
"bindings": ["APP_STORAGE"]

Use it

import { imageSrcSet, imageUrl } from "#/lib/images.server";

<img
  src={imageUrl("uploads/cat.jpg", { width: 400 })}
  srcSet={imageSrcSet("uploads/cat.jpg", [400, 800])}
  width={400} height={300} alt="The cat" loading="lazy"
/>
  • src/routes/api/stackly/image.$.ts answers those addresses; leave it as it is. Or call resizedImage(key, options) in your own server code.
  • Options: width, height, fit (scale-down, contain, cover, crop, pad), format (webp, avif, jpeg, png), quality.
  • Delete with deleteImage(key) to drop the original and its sizes.

Limits

Images up to 20 MB and 4000 px a side. Sizes are kept under _stackly/images/ in storage.

Locally

On your machine and a local Stackly the original is answered unchanged: resizing runs on Cloudflare.

All app features