Production tool
Image Ratio Calculator
Enter a source size and a target to get distortion-free dimensions, the closest standard ratio, and export sizes for 1x, 2x and 3x displays.
Inputs
Output
Export sizes
| Display | CSS px | Physical px |
|---|
How to use it
- Enter your source image dimensions — you can read them from any file's properties dialog.
- Choose whether you know the final width or the final height, then type that value.
- Read the missing dimension. Exporting at these exact numbers keeps the image undistorted.
- If a platform demands a specific ratio, pick it in the crop list to see how much of each edge you will lose.
- Copy the 2x or 3x row for retina assets; the CSS px column is what you write in your stylesheet.
How it is calculated
Keeping proportions means preserving the ratio between the two sides, so the unknown side solves from the known one:
ratio = sourceWidth / sourceHeight newHeight = newWidth / ratio newWidth = newHeight × ratio gcd-based label: divide both sides by their greatest common divisor
Cropping to another ratio centres the frame and removes the excess from the longer edge. Trim per side is:
trimWidth = sourceW − sourceH × targetRatio (if positive) trimHeight = sourceH − sourceW / targetRatio (otherwise)
Display multiples simply multiply the CSS size by the device pixel ratio: 2x devices want double the physical pixels, 3x want triple.
Worked example
A 4000 × 3000 photo has a 4:3 ratio. Locking height at 1080px gives a width of 1080 × 4/3 = 1440px. If you then crop that result to 16:9 for a thumbnail, the width must fall from 1440 to 1920 — impossible at this height — so instead the height is trimmed: 1440 × 9/16 = 810px, meaning 270px total (135px top and bottom) is removed.
Where this works, and where it does not
Use it for thumbnails, social assets, hero images, video frames and any asset that must fit a fixed layout slot. The arithmetic is identical everywhere, so the export sizes are portable between design tools.
It does not open your image file, so it cannot tell you whether the subject survives the crop, nor estimate final file weight — that depends on compression and content. It also assumes pixel-exact inputs; if your source has non-square pixels, correct that first.