Aspect Ratio Calculator
Get aspect ratios like 16:9 and scale dimensions proportionally.
Get aspect ratios like 16:9 and scale dimensions proportionally. Enter your numbers and get an instant result.
Enter a source width and height in pixels and this page reduces them to the smallest whole-number ratio, prints the width divided by the height to four decimals, and reports the total pixel count in megapixels.
A second pair of fields scales proportionally: type a target width and the matching height is filled in, or type a target height and the width is filled in, with the result rounded to a whole pixel.
Four presets load common sizes: 1920 by 1080, 1080 by 1920, 1080 by 1080 and 1024 by 768. Every figure recalculates as you type; the page does not read an image file.
How the ratio is reduced
The greatest common divisor of width and height is found by Euclid's algorithm, and both sides are divided by it. 1920 by 1080 has a divisor of 120, which is where 16:9 comes from.
When the two numbers share no divisor the ratio is left unreduced: 1920 by 1081 prints 1920:1081, which is correct arithmetic and almost never the ratio you wanted. That is usually a sign the height was cropped by a pixel.
The decimal figure is width divided by height to four places, so 16:9 prints 1.7778 and a square prints 1.0000.
- Reduced ratio: width and height divided by their GCD
- Decimal ratio: width divided by height, four decimals
- Total pixels: width times height, in megapixels to two decimals
What the proportional scaler rounds
Only the field you did not type is calculated, and it is rounded with `Math.round`. At 1920 by 1080 a target width of 1000 yields 563, not 562.5, so the scaled pair is one pixel off the exact ratio.
The scaler preserves the whole frame. It does not crop, letterbox or apply a target ratio of its own, so asking for 1:1 output from a 16:9 source is not something these fields do.
How to use the size fields
Enter the source Width and Height in pixels, or load one of the four Popular Presets: 16:9, 9:16, 1:1 or 4:3. The reduced ratio, the decimal to four places and the total megapixels recalculate as you type.
Scale with the Proportional Scaler: type a Target Width and the matching height fills in, or type a Target Height and the width fills in, rounded to a whole pixel. The page never reads an image file.
What to Expect
Best for
- Working out what 1920 by 1080 reduces to before writing a CSS rule
- Filling in the missing side of a proportional resize
- Checking whether two image sizes really share a ratio
Not ideal for
- Resizing or cropping an actual image file, which this page never opens
- Snapping to a named standard ratio such as 4:5 or 21:9, which is not offered
- Designing a responsive container, where the ratio is a CSS concern rather than an arithmetic one
What this tool keeps
- The reduced ratio as whole numbers, never as a decimal
- Four decimal places on the ratio and two on the megapixel count
- The pair you typed, with only the opposite field recalculated
What may need cleanup
- A one-pixel rounding error in the scaled dimension, which an exact resize would not have
- An unreduced ratio such as 1920:1081, which means the source height is odd
- The megapixel figure rounded to two places, which hides a few thousand pixels
Common errors
- Reading 1920:1081 as a design ratio rather than a one-pixel crop
- Expecting the scaler to keep the height exactly proportional after rounding
- Entering a zero or negative dimension, which blanks the result instead of warning
Example use cases
- A developer writing an `aspect-ratio` rule for a video embed
- A photo editor checking whether a crop kept 3:2
- A designer scaling a 1920-wide mock to a 1280-wide export
Sample input
Width 1920, height 1080, then target width 1280.
Sample output
16:9, decimal 1.7778, 2.07 MP, and the target height fills in as 720.
Who this is for
- Front-end developers writing layout rules
- Photographers and video editors checking a crop
- Designers scaling a mock-up to an export size
Frequently asked questions
What does the aspect ratio page calculate?
It reduces a width and height to the smallest whole-number ratio, prints the width divided by the height to four decimals, and reports the megapixel count.
Can it resize or crop my image file?
No. It never opens a file; it only does the arithmetic on the numbers you type.
Why is the scaled dimension sometimes one pixel off?
The scaler rounds to a whole pixel, which an exact resize would not; the unresized ratio is the exact answer.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.