Digital and AI · Calculator

Crop or fit: how to change an image’s aspect ratio

Enter the photo size and the aspect ratio you need, and the calculator shows how much is cut off when cropping or how much the margins take up when fitting, and the exact sizes in pixels.

Exact calculation Formula shown Your data stays in your browser

Your data

1. What to do

Cropping fills the whole frame, fitting keeps the whole image.

2. Original

The size of your image in pixels.

In pixels (from the file properties or an image editor).
If the photo looks vertical on screen but the properties show a width larger than the height, swap the numbers.
3. New aspect ratio or size

A ready-made ratio, your own ratio or the exact size of the result.

A decimal number is fine: for example, 2.39 and 1.
The second number of the ratio: for 21:9 it is 9.
The size you need, in whole pixels.
4. Frame position

Which part of the original to keep when cropping.

0% means from the left edge, 50% centred, 100% to the right edge.
0% means from the top edge, 50% centred, 100% to the bottom edge.

How we calculate

  1. ratio = width ÷ height (from a ready-made ratio, your own or the exact size of the result)
  2. crop: area width = the smaller of (original width; original height × ratio), area height = the smaller of (original height; original width ÷ ratio); rounded to a whole pixel, half up
  3. area offset = ⌊(original − area) × frame position ÷ 100⌋ (rounded down, the extra pixel stays on the opposite side)
  4. fit: frame = the larger of the same values; for an exact size, scale = the smaller of (result width ÷ original width; result height ÷ original height), image = original × scale, rounded to a whole number; left or top margin = ⌊margins ÷ 2⌋, the rest on the other side
  5. share cut off = 1 − area of the region ÷ area of the original; share of margins = 1 − area of the original ÷ area of the frame; both before pixel rounding and always equal for the same ratios

Assumptions

  • The image is not stretched: objects in the frame keep their shape.
  • Area shares are calculated from the exact geometry, sizes are rounded to a whole pixel.
  • The frame position is centred by default; change it if the main subject is off-centre.

Limitations

  • The calculator does not process the file: it works out sizes, offsets and shares, and you crop or add margins in your editor using these numbers.
  • Recommended sizes for particular social networks and platforms are not set here: they change, so check them in the platform’s help pages.
  • Quality after enlarging, compression, colour profile and file size are not assessed. Print sizes and pixel density are worked out by a separate calculator.

Sources

A universal formula with no external constants. Default values are labelled as approximate examples, not verified facts.

Questions and answers

Will the calculator crop my photo itself?

No. It does not open or upload the file; it only works out which area to keep, which pixel it starts at and what margins to add. You enter these numbers in an image editor, in the crop or canvas size fields.

Why are the cropping and margin percentages the same?

Both depend only on two ratios: the original and the new one. The difference is what happens to that share: cropping removes part of the image, fitting adds empty bands and the image stays whole.

Can I change the ratio without cropping and without margins?

Only by stretching the image along one axis, and that distorts objects and faces. There is deliberately no such mode here: cropping or margins are the only ways to keep the right shape.

Why is the result’s ratio slightly different from the one I set?

Pixels can only be whole. For a frame 3,000 px high to have a 16:9 ratio, the width would have to be 5,333.33 px, so the calculator rounds it to 5,333 and shows by what percentage this changes the ratio.

Related tools

The calculator does not change or upload your file; it only works out the sizes. Recommended sizes for social networks and platforms are not set here: they change, so check them in the platform’s help pages.

Formula version aspect-ratio-crop-fit@1.0.0 · checked 17 October 2026

Checked by the Calc editorial team: three independent implementations of the formula, test cases and the live page on a phone. Last check: 18 October 2026