Compute missing width or height to keep any aspect ratio.
🔒 100% client-side. Enter a ratio and one dimension; the other is computed as dim = known × (target / source).
The Aspect Ratio Calculator is based on the following formula:
h₂ = h₁ × ( w₂ / w₁ )
Variables: w₁: original width (px) h₁: original height (px) w₂: new width (px) h₂: new height (px)
Resize while keeping the aspect ratio: the height scales by the same factor as the width. Given one new dimension, the other is computed to preserve the proportion.
Worked example: Step 1: Original image is 1920 × 1080; new width is 1280. Step 2: Scale factor = 1280 / 1920 = 0.6667. Step 3: h₂ = 1080 × 0.6667 = 720. Result: 1280 × 720, the same 16:9 ratio.
An aspect ratio is the proportional relationship between width and height (expressed as W:H, like 16:9). When you resize an image, video, or container, keeping the ratio constant prevents stretching and distortion. This calculator takes any ratio plus one dimension and computes the other, with a live preview of the resulting shape.
Given a ratio W:H, the dimensions are always proportional: width ÷ height = W ÷ H. So if you know the width, height = width × (H ÷ W); if you know the height, width = height × (W ÷ H). For a 16:9 video at 1920px wide, the height is 1920 × (9 ÷ 16) = 1080. The calculator handles the division for any ratio, including odd ones like 5:4 or 21:9.
When fitting a ratio into a fixed box, contain scales the image so the whole thing is visible, possibly leaving letterbox bars. Cover scales so the box is completely filled, cropping the overflow. CSS object-fit and background-size use these same terms. Pick contain when you must show the entire image; pick cover when the box must stay full (e.g. hero backgrounds).
More tools you might find useful
Four corner sliders to CSS code, elliptical slash syntax included.
Test color contrast against WCAG AA and AAA accessibility levels.
Convert between HEX, RGB, and HSL with a visual picker.
One base color to five harmony schemes, each swatch in hex/rgb/hsl.