Control image dimensions with width, height, fit modes, and gravity.
Resize & Crop
Basic resize
| Param | Type | Range | Description |
|---|---|---|---|
w | integer | 1-8192 | Target width in pixels |
h | integer | 1-8192 | Target height in pixels |
dpr | integer | 1-3 | Device 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.
| Mode | Param | Behavior |
|---|---|---|
| Cover | fit=cover | Fill the target area, crop overflow (default) |
| Contain | fit=contain | Fit within the target area, preserve aspect ratio |
| Fill | fit=fill | Stretch to exactly fill (may distort) |
| Scale down | fit=scale-down | Like contain, but never upscales |
| Crop | fit=crop | Same as cover (explicit crop intent) |
| Pad | fit=pad | Contain + 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.
| Value | Description |
|---|---|
center | Center of image (default) |
top | Top edge |
bottom | Bottom edge |
left | Left edge |
right | Right edge |
top-left | Top-left corner |
top-right | Top-right corner |
bottom-left | Bottom-left corner |
bottom-right | Bottom-right corner |
auto | Saliency-based smart crop |
face | Face 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.