Control image dimensions with width, height, fit modes, and gravity.

Resize & Crop

Basic resize

ParamTypeRangeDescription
winteger1-8192Target width in pixels
hinteger1-8192Target height in pixels
dprinteger1-3Device pixel ratio multiplier
?w=800          → 800px wide, height auto
?h=600          → 600px tall, width auto
?w=800&h=600    → 800x600 (behavior depends on fit mode)
?w=400&dpr=2    → 800px actual (for 2x displays)

Fit modes

Control how the image is resized when both w and h are specified.

ModeParamBehavior
Coverfit=coverFill the target area, crop overflow (default)
Containfit=containFit within the target area, preserve aspect ratio
Fillfit=fillStretch to exactly fill (may distort)
Scale downfit=scale-downLike contain, but never upscales
Cropfit=cropSame as cover (explicit crop intent)
Padfit=padContain + pad with background color
?w=800&h=600&fit=cover      → fills 800x600, crops overflow
?w=800&h=600&fit=contain    → fits inside 800x600
?w=800&h=600&fit=pad&bg=ffffff  → contains + white padding

Gravity

When cropping (cover/crop mode), gravity controls which part of the image is kept.

ValueDescription
centerCenter of image (default)
topTop edge
bottomBottom edge
leftLeft edge
rightRight edge
top-leftTop-left corner
top-rightTop-right corner
bottom-leftBottom-left corner
bottom-rightBottom-right corner
autoSaliency-based smart crop
faceFace detection smart crop
?w=400&h=400&fit=cover&g=top      → crop from the top
?w=400&h=400&fit=cover&g=auto     → smart crop (saliency)
?w=400&h=400&fit=cover&g=face     → smart crop (face detection)

See Smart Crop for details on auto and face modes.

Background color

Used with fit=pad to set the padding color.

?w=800&h=600&fit=pad&bg=ffffff    → white padding
?w=800&h=600&fit=pad&bg=000000    → black padding
?w=800&h=600&fit=pad&bg=f5f5f5    → light gray padding

The bg value is a 6-character hex color without the #.

Dimension bucketing

Spronta snaps requested dimensions to perceptual buckets (~5% geometric spacing). This means w=800 and w=812 produce the same cached variant, improving cache hit rates without visible quality difference.