Optimise images
Add query parameters to a file read and Strovio returns a resized, recompressed image instead of the original. It works on JPEG, PNG, WebP, AVIF and GIF files (the first frame). The first request for a size makes it and stores it; later requests are served from that stored copy.
It works in two places:
GET https://strovio.xyz/api/v1/files/<path>?w=640&format=autowith your API key, for servers and agents.https://strovio.xyz/share/<token>?w=640&format=autoon a share link, with no key, so it can go straight into animgtag.
Without any of these parameters both URLs behave exactly as before: the API returns the file's details as JSON and a share link downloads the original.
Parameters
| Parameter | Values | Default |
|---|---|---|
w | Width in pixels, 1 to 4096 | The image's own width |
h | Height in pixels, 1 to 4096 | The image's own height |
fit | cover (crop to fill the box), contain (fit inside and pad), inside (fit inside, no padding). Used only when both w and h are given. | cover |
format | auto, avif, webp, jpeg, png | auto |
q | Quality, 1 to 100, rounded to the nearest 5 | 75 |
A parameter that is out of range, or given twice, returns 400 invalid_request. Transform parameters on a file that is not an image return 400 unsupported_image.
- Widths snap to a fixed ladder: 16, 32, 48, 64, 96, 128, 256, 384, 640, 750, 828, 1080, 1200, 1920, 2048 and 3840. A request is rounded up to the next step, so
w=600returns a 640 pixel image, and anything above 3840 returns 3840. A height on its own snaps to the same ladder. With bothwandh, the height is scaled with the width so the shape you asked for is kept. - Images are never enlarged: asking for more pixels than the original has returns the original size.
- Output is at most 4096 pixels on each side.
- Photos are turned the right way up from their EXIF orientation, and metadata such as EXIF and GPS is removed.
- `format=auto` returns AVIF if the request's
Acceptheader listsimage/avif, otherwise WebP if it listsimage/webp, otherwise the original format (PNG for a GIF). Browsers send these headers on their own. The response hasVary: Accept. - SVG files are returned unchanged, with
X-Strovio-Transform: skipped; reason=svg. - Originals up to 25 MB and 50 megapixels are transformed. Larger ones are returned unchanged; over 25 MB that is a
302redirect to a one-hour signed URL for the original.
Examples
curl -o cat-640.avif \
-H "Authorization: Bearer $STROVIO_API_KEY" \
-H "Accept: image/avif,image/webp,*/*" \
"https://strovio.xyz/api/v1/files/photos/cat.jpg?w=640&format=auto"In a web page, from a share link:
<img
src="https://strovio.xyz/share/<token>?w=640&format=auto"
srcset="https://strovio.xyz/share/<token>?w=640&format=auto 640w,
https://strovio.xyz/share/<token>?w=1200&format=auto 1200w"
sizes="(max-width: 700px) 100vw, 700px"
alt="A cat"
/>With the TypeScript SDK:
import { StrovioClient, shareImageUrl } from "strovio-sdk";
const strovio = new StrovioClient();
const url = strovio.imageUrl("photos/cat.jpg", { width: 640, format: "auto" });
const { data, contentType } = await strovio.getImage("photos/cat.jpg", { width: 640 });
const forImgTag = shareImageUrl("https://strovio.xyz/share/<token>", { width: 828 });With the MCP server, the image_url tool returns the URL and can save the image to a local path.
Response headers
| Header | Meaning |
|---|---|
X-Strovio-Transform: applied | The size was made for this request |
X-Strovio-Transform: cached | A stored copy was served |
X-Strovio-Transform: skipped; reason=... | The original was served unchanged. Reasons: svg, too_large, allowance (monthly allowance used), storage (storage full), plan_inactive, variant_limit (this image already has 50 sizes), busy (try again shortly), unprocessable (the file could not be read as an image) |
ETag | Changes when the original or the parameters change. Send it back as If-None-Match to get 304 Not Modified. |
Cache-Control | private, max-age=86400 on the API and public, max-age=3600 on share links, so a revoked link stops working within an hour, as its signed download URLs do. Unchanged originals served after a skip are no-store. |
Storage, allowance and limits
- Each stored size counts toward your account's storage, and never appears in file lists or the dashboard's folders.
- Replacing an original (uploading to the same path), renaming, moving or deleting it removes its stored sizes. The next request makes them again from the new file.
- Each plan has a monthly allowance of new sizes. Serving a stored size is free.
| Trial | Pro | Team | |
|---|---|---|---|
| New image sizes a month | 1,000 | 25,000 | 100,000 |
When the allowance is used up, or your storage is full, requests still succeed: they return the original with X-Strovio-Transform: skipped; reason=allowance (or reason=storage), never an error. The allowance resets on the first day of each month (UTC). See your usage on the billing page.
- New sizes, and originals served in their place, are rate-limited to 600 a minute for each account and 120 a minute from each network (an IPv4 /24 or IPv6 /48). Above that the API answers
429 rate_limitedwithRetry-After: 60. Stored sizes and304answers are not rate-limited. - Each version of an image can have up to 50 stored sizes. Replacing the image starts again.
- Requests on a share link count toward the link owner's allowance.