Type Alias ImageOptions
cache?: ImageCache | false;
encoder: ImageEncoder;
hints?: boolean;
lazy?: LazyOptions | false;
maxBytes?: number;
maxWidth?: number | false;
minBytes?: number;
paths?: RegExp;
png?: PngMode;
quality?: { default?: number; saveData?: number; slow?: number };
responsive?: ResponsiveOptions | false;
timeoutMs?: number | false;
width?: { fallback?: number };
}
Properties
Optionalcache
converted bytes by content hash; default an in-memory cache of 64 MiB, false for none
encoder
converts the bytes; see tinyimgEncoder
Optionalhints
add Accept-CH to HTML responses so the browser sends the width hints; default true
Optionallazy
Adds loading="lazy" and decoding="async" to <img> tags in HTML after the first skip
(default 2), and loading="lazy" to <iframe> tags with iframes; default false, no page
is touched for it. See rewriteLazy.
Optionalmax Bytes
largest origin file converted, in bytes; default 15,000,000
Optionalmax Width
The width ceiling, 1 to 16384, for a request that carries no width hint; default 2560, false
for none. A Sec-CH-Width or a viewport and DPR pair wins over it. An image narrower than the
ceiling keeps its size.
Optionalmin Bytes
smallest origin file converted, in bytes; default 4096, so icons and sprites stay as they are
Optionalpaths
the paths converted, tested against the pathname; default /\.(?:jpe?g|png)$/i
Optionalpng
How a PNG becomes WebP; default 'lossy'. 'lossless' encodes every PNG without loss, and
'auto' encodes a PNG under 200 KB both ways and serves the smaller (a screenshot or a flat
graphic is often smaller lossless, a photograph in a PNG is not). A JPEG is always lossy. The
mode is part of the cache key and the ETag of a PNG that is not 'lossy'.
Optionalquality
WebP quality, 1 to 100, by the visitor's connection; defaults 80, 65 for Save-Data: on, 70 for ECT of slow-2g, 2g or 3g
Optionalresponsive
Adds a srcset of ?spool-w=<width> variants to same-origin <img> tags in HTML, so a
browser that sends no Sec-CH-Width (Firefox, Safari) still asks for a smaller file; default
false, no page is touched for it. See rewriteResponsive.
Optionaltimeout Ms
How long the proxy waits for the encoder, in milliseconds; default 10,000, false to wait
without limit. When the time runs out the visitor gets the origin's bytes, and the encoder is
left to finish: a result that arrives late is cached for the next request.
Optionalwidth
fallback is the width ceiling for a request that names none; default maxWidth, and it wins over maxWidth when both are set
what
spoolProxy({ images })takes