HomeEveryday Life › Aspect Ratio Calculator

Aspect Ratio Calculator

Reduces a width and height to their simplest ratio and decimal value, identifies the closest common ratio (16:9, 4:3, 3:2, 21:9 …) and scales the dimensions to a new width or height while keeping the ratio.

When to use

You need the aspect ratio of an image, screen or video, or the matching height for a new width (or width for a new height) when resizing.

Do not use when: You need pixel density, file size or a crop to a different ratio; this only keeps the existing proportions.

Formula

ratio = (width / g) : (height / g) with g = gcd(width, height); ratio_decimal = width / height; scaled_height = new_width × height / width; scaled_width = new_height × width / height

Inputs

ParameterTypeUnitRequiredDescription
widthnumberyesWidth in any unit (pixels, cm …). Range: > 0, ≤ 1000000000
heightnumberyesHeight in the same unit. Range: > 0, ≤ 1000000000
new_widthnumbernoOptional target width; the matching height is returned as scaled_height. Range: > 0, ≤ 1000000000
new_heightnumbernoOptional target height; the matching width is returned as scaled_width. Range: > 0, ≤ 1000000000

Outputs

OutputTypeUnitDescription
ratiostringSimplest integer ratio width:height (values with decimals are scaled to integers first).
ratio_decimalnumberwidth / height.
closest_common_ratiostringNearest of 1:1, 5:4, 4:3, 3:2, 16:10, 16:9, 1.85:1, 2:1, 21:9, 2.39:1 (or their portrait forms), by ratio.
orientationstringlandscape, portrait or square.
scaled_heightnumbernew_width × height / width (only when new_width is given).
scaled_widthnumbernew_height × width / height (only when new_height is given).

Example

1920 × 1080, resize to width 1280: {"width":1920,"height":1080,"new_width":1280}{"ratio":"16:9","ratio_decimal":1.7778,"closest_common_ratio":"16:9","orientation":"landscape","scaled_height":720}

1080 × 1350 portrait, resize to height 675: {"width":1080,"height":1350,"new_height":675}{"ratio":"4:5","ratio_decimal":0.8,"closest_common_ratio":"4:5","orientation":"portrait","scaled_width":540}

GET https://tttkmbb.com/api/v1/calculate/aspect-ratio?width=1920&height=1080&new_width=1280

Machine access

Sources

FAQ

Why is my 1366 × 768 screen shown as 683:384 and not 16:9?

683:384 is the exact simplified ratio (1.7786); it is only approximately 16:9 (1.7778), which is why closest_common_ratio is reported separately.

Scaled dimensions are not whole pixels. What should I do?

Round to the nearest integer (or to an even number for video codecs); the tiny change in ratio is invisible.

Related calculators