Skip to content

HTTP API

Image routes support GET and HEAD. Examples omit authentication parameters; see signing for when they are required.

RouteBehavior
/healthJSON liveness; does not check storage or codecs
/metricsPrometheus text; disabled by default, Bearer token when enabled
/<key>Original bytes from the main source
/<key>?w=640&f=webpQuery transformation
/<key>?p=card&f=webpPreset transformation
/tr:f-webp,w-640,q-75/<key>Path-token transformation
/og/<key>Fixed social JPEG with watermark from the main source
/static/<key>Original bytes from local STATIC_DIR
/favicon.icoEmbedded Pixerve icon; no redirect, transformation, or source read

og/, static/, and tr: are reserved prefixes. /favicon.ico serves the built-in icon. On /og/ and /static/, query transform options do not override fixed route behavior. On /tr: routes, transform settings come from path tokens; query transform fields do not override them. Authentication and pv can still come from the query. Keys are relative paths. Percent-encode special characters in URLs. Empty path components, . / .., backslashes, colons, and control characters are rejected.

ParameterAccepted valuesDefault
wInteger 1–2400Derived from aspect ratio if only h is given
hInteger 1–2400Derived from aspect ratio if only w is given
qInteger 1–10095; presets override this
fauto, jpeg, png, webp, avifAutomatic for transforms
fitcover, contain, fill, inside, outsidecover
foPositions below, entropy, attentioncenter
blFinite sigma 0.3–100No blur
bg3/4/6/8 hex digits, without #Transparent contain padding; white JPEG flattening
pthumbnail, card, article, wide, ogNo preset

Global/open-mode limits can reject syntactically valid values. PNG uses compression level 9; q does not tune PNG compression. Parameters and named values are case-sensitive. Unknown query fields are ignored and stripped by canonicalization. Duplicate query keys and duplicate token keys return 400.

/photos/example.jpg?w=640&h=360&fit=cover&fo=attention&f=webp&q=75
/tr:f-png,w-600,h-600,bg-ffffff,fit-contain/photos/example.jpg
/photos/example.jpg?w=960&bl=1.5&f=jpeg
ModeBehavior with both dimensions
coverPreserve aspect ratio, cover the box, crop
containPreserve aspect ratio, fit inside, pad to canvas
fillResize axes independently; may distort
insideFit inside without padding
outsideCover the box without final cropping

Ordinary transforms do not upscale source pixels. Cover may return a smaller result for small sources; contain can add a larger canvas around an un-enlarged image. A single dimension preserves aspect ratio, including in fill mode. The dedicated OG route can upscale. EXIF orientation is applied before effective output geometry is checked.

Positions: center, top, bottom, left, right, top_left, top_right, bottom_left, bottom_right. entropy and attention use libvips smart cropping. Focus affects cover cropping, not general watermark placement or contain padding.

bg=fff is white; bg=0000 is transparent black. Four/eight-digit forms include alpha. JPEG flattens alpha onto the RGB background, defaulting to white. Transforms convert to sRGB and strip metadata. Raw/static preserve original bytes and metadata, with content type inferred from the filename.

PresetWidthHeightQualityFormatFit / focus
thumbnail32018075WebPcover / center
card64036075WebPcover / center
article960derived80WebPinside / center
wide1280derived80WebPinside / center
og120063070JPEGcover / entropy

Explicit options override preset values. p=og is an ordinary transform preset: it adds no watermark and does not enable upscaling. Use /og/<key> for both. PRESETS_ONLY=true accepts normalized preset options with a different format allowed. It does not disable raw/static routes.

/og/<key> produces a 1200 × 630, quality-70 JPEG with entropy crop and watermark. The watermark is composited at the top-left origin at its existing dimensions; it is not resized or repositioned. It must fit the output. A transparent 1200 × 630 overlay can position artwork within that canvas.

Missing f or f=auto prefers explicitly accepted AVIF, then WebP, then JPEG fallback. An explicit media type with q=0 is skipped. This is a format preference policy, not full HTTP quality ranking or a 406 negotiator; wildcards alone do not enable AVIF/WebP. Automatic responses include Vary: Accept; explicit formats, social JPEGs, and raw/static do not. See CDN delivery.

By default, query/preset/alternative parameter order redirects with uncached 308 to a canonical URL. Authentication is checked first. Use SDK- or CLI-generated URLs to avoid that round trip.

pv selects the configured pipeline. URLs without it remain mutable. A different pv returns 410 after applicable authentication. Public asset signatures with missing/wrong pv return 403.

HeaderMeaning
Content-TypeEncoded format, or filename-derived raw type
ETagWeak FNV-1a validator for output bytes
Cache-ControlPublic mutable/immutable or private no-store
Vary: AcceptAutomatic format transforms only
X-Img-CacheOrigin path: RAM, DISK, MISS, SHARED
Server-TimingOrigin handler duration, such as img;dur=2.350
X-Content-Type-Optionsnosniff on successful images and error PNGs
X-Img-ErrorDiagnostic message on image errors
Retry-After1 on application 429 / 503

If-None-Match supports lists, weak/strong comparisons, and *. A match returns 304 with ETag/cache policy and no body. HEAD has no body but may require source loading/encoding on a cold cache. The weak ETag is not a cryptographic fingerprint.

StatusMeaning
200Image, health, or authorized metrics
304Conditional image match
308Follow canonical Location
400Invalid path/transform/query, duplicate fields, preset mismatch, or mixed signature types
403Required signature/origin token missing, invalid, expired, or disallowed; output format forbidden by unsigned-request policy
404Source absent, or metrics disabled/unauthorized
405Unsupported method
409Source does not match hash in its filename
410Pipeline version unavailable
413Source bytes, pixels, or transform policy exceeded
422Corrupt/unsupported image, missing codec, or another native transform error
429Open-mode IP window exceeded
500Processing task failed
502Source backend error other than absence/size rejection
503Request/job capacity exhausted or shutdown
504Source read exceeded 30 seconds

Image errors, including unsupported methods, return a PNG with the original HTTP status and Cache-Control: no-store. X-Img-Error contains the diagnostic message. HEAD returns the same headers and content length with no body. Existing Retry-After and Allow headers remain available. Errors have no ETag.

/health and /metrics retain their operational response formats. Errors from an upstream proxy or CDN are outside Pixerve’s response handling.

Policy rejections use these X-Img-Error values and Cache-Control: no-store:

StatusX-Img-ErrorSetting
403Output format is not allowed for unsigned requestsOPEN_ALLOWED_FORMATS
413Unsigned image dimensions exceed configured limitsOPEN_MAX_W, OPEN_MAX_H, OPEN_MAX_MP
413Unsigned image blur exceeds configured limitOPEN_MAX_BLUR
413Output pixel limit exceededMP_LIMIT

Dimension and pixel checks also apply to the actual decoded output when a requested width or height is omitted. PNG is supported; to allow it for unsigned requests, include png in OPEN_ALLOWED_FORMATS. Signed transforms use the general limits.