Sizing Rules

Last updated


This page explains how s, w, and h translate into output dimensions, including the default downscale and edge cases.

Computation


Given an original of width W and height H, every target is capped at the original dimensions; images are never upscaled.
ParametersLandscape (W > H)Portrait or square (W ≤ H)
sheight = min(s, H), width proportionalwidth = min(s, W), height proportional
w and hwidth = min(w, W), height = min(h, H), center-cropped with sharp's default coverSame
Only wwidth = min(w, W), height proportionalSame
Only hheight = min(h, H), width proportionalSame
None, and min(W, H) > 1024width = 1024, height proportionalheight = 1024, width proportional
None, and min(W, H) ≤ 1024Original sizeOriginal size

The proportional edge is rounded down with Math.floor.

Examples


OriginalParametersOutput
4000×3000none1024×768
3000×800none3000×800 (short edge not above 1024)
4000×3000s=480640×480
4000×3000w=800800×600
4000×3000w=400&h=400400×400 (cropped)
600×400w=1200600×400 (no upscale)
中文