Aspect Ratio Calculator: Simplify, Scale, and Fit Any Frame
A frame can be large or small and still have the same shape. A 160 by 90 thumbnail and a 3840 by 2160 television both use a 16:9 ratio, because the relationship between width and height is the same. The Aspect Ratio Calculator makes that relationship visible: enter two dimensions, get the simplest ratio, then scale either side, preview a fit, or copy CSS that preserves the shape.
The tool is built for the small decisions that appear in image, video, and layout work. A designer needs a portrait crop that matches a social template. A developer needs a placeholder that keeps its height while the page loads. An editor needs to know whether a still will lose its subject when it fills a banner. Each task starts with a ratio, and each answer is faster when the arithmetic and the visual check sit on one screen.
What the calculator solves
The work area is split into three tabs. Dimensions reduces a width and height to a simplified ratio. Scale locks a ratio and calculates the missing side from a known width or height. Advanced contains the fit preview, CSS output, comparison, and batch table. The separation matters because the questions are different: one tab identifies a shape, another resizes it, and the advanced tools test how it behaves inside a frame.
The Dimensions tab reports more than a colon pair. It shows the decimal value, the percentage form, a one-to-N form, and the closest standard ratio with an error percentage. That extra context helps when a size is close to a familiar format but not an exact match. A 1200 by 628 image is not exactly 1.91:1, and the error value makes the difference visible instead of leaving it as a guess.
An optional image picker reads the pixel dimensions from the file header. The file stays in the browser. The calculator does not upload the image, and the same is true when dimensions are typed by hand. This is useful for client work, internal assets, and any file that should not leave the device just to answer a geometry question.
How to simplify a width and height
The simplified ratio comes from the greatest common divisor. Divide both dimensions by the largest number that divides them evenly, and the result is the smallest whole-number pair. For 1920 and 1080, the greatest common divisor is 120. Dividing both sides gives 16 and 9, so the ratio is 16:9. The decimal form is 1920 divided by 1080, or about 1.778.
The same method works for less familiar sizes. A 1024 by 768 display has a greatest common divisor of 256, which gives 4:3. A 1080 by 1350 portrait post has a divisor of 270, which gives 4:5. A 3840 by 2160 frame has a divisor of 240, which gives 16:9 again. The ratio stays the same when both sides are multiplied or divided by a common number.
The formula is simple enough to write down:
$$\text{ratio} = \frac{\text{width}}{\text{height}}$$
That decimal is useful for comparisons, but it is not the same as the simplified pair. A 16:9 frame has a decimal of roughly 1.778, while a 16:10 frame has a decimal of 1.6. The first is wider. The calculator shows both forms because one is better for a label and the other is better for sorting or measuring a difference.
Units do not change the ratio as long as both sides use the same unit. A print that is 16 inches wide and 9 inches tall has the same 16:9 shape as a video that is 1920 pixels wide and 1080 pixels tall. Enter inches, centimeters, or pixels together, and the ratio remains valid. Mixing units in one pair is the mistake to avoid.
How to scale one side without breaking the ratio
Scaling starts with a known side and a ratio. If the ratio is W:H and the width is known, the height is the width multiplied by H and divided by W. For a 16:9 frame that is 1280 pixels wide, the height is 1280 times 9 divided by 16, which equals 720 pixels. If the height is known instead, the width is the height multiplied by W and divided by H.
$$\text{height} = \frac{\text{width} \times H}{W}$$
$$\text{width} = \frac{\text{height} \times W}{H}$$
The Scale tab applies that formula in either direction. It also accepts a percentage or a scale factor, which is helpful when an asset has to grow or shrink by a fixed amount. A 50 percent scale on a 1920 by 1080 frame gives 960 by 540. A 200 percent scale gives 3840 by 2160. The ratio does not change because both sides move by the same factor.
Pixel results are not always whole numbers. A 1080 by 1920 vertical frame scaled to a width of 608 produces a height of about 1080.9 if the ratio is preserved exactly. The rounding control resolves that: decimals keep the exact value, whole pixels round to the nearest integer, and even pixels round to an even number, which can be useful for video encoding. The important point is that the rounding rule is a choice, not a hidden correction.
Contain versus cover: choose the fit before the crop
A ratio describes a shape, but a frame can have a different shape from the image placed inside it. Contain and cover are two ways to resolve that mismatch. Contain scales the image until the whole image fits inside the frame. The result may show empty bars on the sides or above and below. Cover scales the image until the frame is filled, then crops the overflow. The frame has no bars, but the edges of the image disappear.
The fit panel asks for a source size and a frame size, then reports the scaled dimensions, the bar or crop amounts, the scale percentage, and the share of the frame that the image uses. That last number is a quick way to see how much of a frame is empty under contain. A wide image placed in a square frame can use only a little more than half of the frame height, which is a strong signal that a different crop or a different layout may be better.
This check is more useful than a verbal rule because the answer depends on both shapes. A 16:9 image in a 16:9 frame needs no bars and no crop. The same image in a 1:1 frame needs either bars or a crop. A 4:5 portrait in a 16:9 banner has the opposite problem: it is much taller than the frame, so cover removes a large part of the top and bottom. Seeing the numbers before export is cheaper than fixing a bad crop after publication.
Turning the ratio into CSS
The CSS output panel writes the rule for the selected ratio in three styles. The modern style uses the aspect-ratio property, which reserves a shape for a box without a padding trick. The legacy style uses a percentage padding-top box for older layouts. The Tailwind style produces utility classes for projects that already use that framework.
The modern rule can be copied with pixels, percent, em, rem, vw, or vh as the unit. A simple 16:9 box can be written as aspect-ratio: 16 / 9;. When a width is also set, the height follows from the ratio. This is useful for image placeholders, video wrappers, cards, and any block that should keep its shape while the page is responsive.
The CSS property and the image fit work together. aspect-ratio controls the shape of the box. object-fit controls how an image fills that box. object-fit: contain shows the whole image and leaves empty space when the shapes differ. object-fit: cover fills the box and crops the overflow. A developer who copies the ratio but forgets the fit rule can still get a stretched or letterboxed result, so the two decisions belong together.
Presets, comparison, and batch checks
The preset library holds 83 formats across common, social, video, device, and print groups. Presets save typing when the target is a known format, and the custom ratio field handles everything else. A preset is a starting point, not a restriction: the scale controls still accept any width or height that fits the chosen ratio.
The comparison panel puts two ratios side by side. It reports both decimal values, the percent difference, and which shape is wider. This is handy when two formats look similar in a list but behave differently in a layout. A 3:2 photo and a 16:10 screen are close enough to invite a guess, but their decimals are 1.5 and 1.6, and the difference shows up when both are placed in the same column.
The batch table accepts up to 100 lines in width by height form. Each line produces a simplified ratio, a decimal, the closest standard ratio, and an error percentage. Lines that cannot be parsed are marked Invalid instead of being silently skipped. The default list includes one invalid line so the behavior is visible on the first visit. For an audit of exported assets, this turns a repetitive check into a single paste.
Common ratios at a glance
| Ratio | Decimal | Typical use |
|---|---|---|
| 1:1 | 1.000 | Square posts, avatars, product tiles |
| 4:3 | 1.333 | Classic monitors, tablets, some cameras |
| 3:2 | 1.500 | Many DSLR and mirrorless photos |
| 16:9 | 1.778 | HD video, YouTube, modern displays |
| 9:16 | 0.563 | Vertical video, stories, phone screens |
| 4:5 | 0.800 | Portrait social posts and feed images |
| 21:9 | 2.333 | Ultrawide monitors and wide cinema frames |
The table is a reference, not a rulebook. A project can use any ratio that serves the composition. What matters is that the width, the height, and the intended frame agree, and that the chosen fit mode is deliberate. A calculator makes those checks fast enough to run before an export instead of after a review.
Frequently Asked Questions
What is the difference between resolution and aspect ratio?
Resolution is the number of pixels in each direction, such as 1920 by 1080. Aspect ratio is the relationship between those two numbers, such as 16:9. Two images can share a ratio while having very different resolutions.
How do I calculate an aspect ratio manually?
Divide both dimensions by their greatest common divisor. For 1280 and 720, the divisor is 80, so the ratio is 16:9. The decimal form is width divided by height, which is about 1.778 for this example.
Can I enter inches or centimeters instead of pixels?
Yes, as long as both sides use the same unit. The ratio is a proportion, so 16 inches by 9 inches has the same shape as 1920 pixels by 1080 pixels. Mixing units in one pair gives a misleading result.
Why does 1920 by 1080 simplify to 16:9?
Both numbers divide evenly by 120: 1920 divided by 120 is 16, and 1080 divided by 120 is 9. No larger whole number divides both, so 16:9 is the simplest form. The decimal value is about 1.778.
Which rounding mode should I use for video?
Use even-pixel rounding when an encoder expects even dimensions, and whole-pixel rounding for ordinary image exports. Use decimals when you need the exact mathematical result or when the value will be passed to another calculation.
What is the difference between contain and cover?
Contain fits the whole image inside the frame, which can leave bars. Cover fills the frame and crops the overflow. The fit panel shows the resulting size, the bar or crop amounts, and the percentage of the frame that is used.
Can I copy the CSS for a ratio?
Yes. The CSS panel generates a modern aspect-ratio rule, a legacy padding-top rule, or Tailwind classes. The modern rule supports pixels, percent, em, rem, vw, and vh, and the copy button places the snippet on the clipboard.
Does the calculator upload my image?
No. The image picker reads the pixel dimensions from the file header in the browser, and the file stays in memory. Typed dimensions are also processed locally, so neither an image nor a size list is sent to a server.
France · SO reputation 2000 · Badges: 0🥇17🥈33🥉 · SO member since 2014