How 16:9 Is Calculated: The Euclidean Algorithm for Aspect Ratio
Upload an image file to the Image Dimension Checker and it automatically displays an aspect ratio like "1920×1080 → 16:9." How do the two numbers 1920 and 1080 become the much simpler numbers 16 and 9? The answer lies in an algorithm Euclid formalized 2,300 years ago: finding the greatest common divisor (GCD).
1. What aspect ratio actually is: a ratio reduced to its simplest form
Aspect ratio refers to the proportion between width and height. The raw pixel values 1920×1080 are technically already a ratio (1920:1080), but by convention it's expressed as the simplest integer pair that can no longer be reduced further. 1920:1080 and 16:9 are mathematically identical ratios, but 16:9 is far easier for a person to recognize and compare. This "reduce to the simplest form" process is exactly what dividing by the greatest common divisor does.
2. Two ways to find the greatest common divisor (GCD)
The traditional way to find the GCD of two numbers is to factor each into primes and multiply the common factors. But prime factorization itself gets slow as numbers get larger. The alternative is the Euclidean algorithm, recorded by Euclid around 300 BCE in his work "Elements." It only requires repeatedly taking division remainders — no factorization needed — so it's much faster, and most software, including the image dimension checker on this site, uses this method.
3. How the Euclidean algorithm works
The core formula is GCD(a, b) = GCD(b, a mod b), and the value of a at the moment b becomes 0 is the greatest common divisor. The actual code this tool uses is a one-line recursive function implementing exactly this formula.
function gcd(a,b){return b===0 ? a : gcd(b, a%b);}
The underlying principle relies on the property that "the common divisors of two numbers are the same as the common divisors of their difference (or remainder)." By repeatedly shrinking the problem down to the remainder of dividing the larger number by the smaller one, the answer naturally falls out at the point where the remainder reaches 0.
4. Working through the real calculation: how 1920×1080 becomes 16:9
Take Full HD resolution, 1920×1080, and walk through the Euclidean algorithm by hand:
| Step | Calculation | Result (remainder) |
|---|---|---|
| 1 | 1920 ÷ 1080 | Quotient 1, remainder 840 |
| 2 | 1080 ÷ 840 | Quotient 1, remainder 240 |
| 3 | 840 ÷ 240 | Quotient 3, remainder 120 |
| 4 | 240 ÷ 120 | Quotient 2, remainder 0 |
1920 ÷ 120 = 16, 1080 ÷ 120 = 9 → the aspect ratio is 16:9
5. Aspect ratios of common resolutions
Running the same process on some familiar resolutions produces the ratios you'd recognize instantly:
| Resolution | GCD | Aspect ratio | Typical use |
|---|---|---|---|
| 1920×1080 | 120 | 16:9 | Full HD, YouTube standard |
| 3840×2160 | 240 | 16:9 | 4K UHD |
| 1080×1080 | 1080 | 1:1 | Instagram square |
| 1200×675 | 75 | 16:9 | Twitter/X card image |
| 2160×3840 | 240 | 9:16 | Vertical video (Shorts/Reels) |
The same GCD logic applies just as well to vertical video with width and height swapped (9:16) — the larger value simply ends up as the height instead. Once you've confirmed the exact aspect ratio, you can use Image Cropper to crop to the ratio you need, or Image Rotator to fix orientation, as follow-up steps.
Frequently Asked Questions
Q. Why is the Euclidean algorithm faster than prime factorization?
A. Prime factorization has to check whether numbers are prime one by one, which gets slower as numbers grow, while the Euclidean algorithm only needs to repeat division remainders, finishing in a handful of steps regardless of magnitude. In practice, even four-digit numbers like 1920 and 1080 finish in just 4 steps.
Q. What happens if the two numbers are coprime (share no divisor but 1)?
A. The GCD comes out to 1, meaning the original pixel values are already the simplest possible ratio. For example, 1920×1081 would display as-is: 1920:1081.
Q. Can images without pixel dimensions, like SVG, still get an aspect ratio?
A. SVG is a vector format, so the viewBox or width/height attribute values are used in place of pixels, calculated the same way. If neither is present, the browser falls back to its default replaced-element size (usually 300×150), so the displayed ratio may not match the actual design intent.
Q. Does this calculation happen on a server?
A. No. Every calculation, including the gcd() function, runs instantly inside your browser, and the image file is never sent to a server.