CalculatorSignAll calculators

Image Aspect Ratio and Fit Inside a Canvas Calculator

Reduce an image aspect ratio and find a whole-pixel fit size without cropping inside a target canvas.

Image Aspect Ratio and Fit Inside a Canvas Calculator

Result
—

Use this calculator on your site

Paste the full code, including the CalculatorSign credit, into a Custom HTML block on your site.

Preview widget

Find how large an image can be placed inside a target pixel canvas without cropping. Enter the image's width and height and the target canvas dimensions. Choose whether a smaller source may be enlarged. The calculator reports a fitted width and height, the reduced original aspect ratio and the unused horizontal and vertical space.

Use pixel dimensions rather than a screen's physical size. For a portrait image, make sure the source width and height represent the intended orientation. A file can carry rotation metadata, and an editor may display it at a different orientation from the stored pixel order. Use the dimensions in the orientation you plan to place.

Compare both width and height limits

Divide target width by original width to find the maximum scale allowed by the width. Divide target height by original height to find the corresponding height limit. Choose the smaller factor so that neither projected dimension exceeds the canvas. When enlargement is disabled, also limit the factor to one.

Apply the same scale to both source dimensions. That preserves their aspect ratio mathematically before converting to pixels. The displayed dimensions are whole pixels rounded down, with a minimum of one pixel on each axis. Rounding can make a slight aspect difference at small dimensions, especially when one dimension would otherwise fall below one pixel.

The reduced ratio comes from the original source width and height. Divide both numbers by their largest common divisor. The result describes the shape independently of its pixel count. The remaining space is calculated by subtracting the fitted width and height from the corresponding canvas dimensions.

Worked example with a 4:3 photo in a widescreen canvas

Enter a 4,032 by 3,024 image and a target canvas of 1,280 by 720. Dividing the source dimensions by 1,008 reduces them to an aspect ratio of 4:3. To fit the canvas width, the scale limit is 1,280 divided by 4,032. To fit its height, use 720 divided by 3,024.

The second factor is smaller, so height determines the fit. At that scale the image measures exactly 960 by 720 pixels. Subtracting 960 from the canvas width leaves 320 horizontal pixels. The height matches the target, leaving no vertical space. If you center the image, you can use 160 pixels of space on each horizontal side.

If you instead scale the same photo to cover the full canvas width, the image becomes 1,280 by 960 pixels. That is taller than the canvas. You would then crop some image content or use distortion to fill the frame. This tool calculates the fit without cropping, so it selects the smaller scale.

Decide how the empty area and scaling will be handled

An image placement system might center the result, align it with a corner or use an existing background. The calculated leftover amounts are the total space across each dimension. If the result leaves an odd number of pixels and must be centered, one side may have one more pixel than the other. The calculator supplies dimensions without deciding where to place that difference.

Removing the enlargement limit allows an image smaller than its canvas to be scaled up. It keeps the source ratio before whole-pixel rounding, but it cannot add detail that the original did not contain. If the output is for a product image or thumbnail, check how the intended editor resamples the file.

Some platforms automatically crop images into cards or use a cover behavior. A fit calculation only ensures the full adjusted image dimensions sit inside the target. If the platform crops the resulting canvas afterward, the placement may still lose content. Use the actual destination dimensions and verify whether it expects a fitted canvas or a pre-cropped picture.

For print, pixel dimensions and print size are related through the resolution at which the image is placed. That relationship is separate from aspect ratio. The result uses pixels only and can help establish shape and available space before you convert to physical measurements.

If you need exact proportional pixel dimensions, choose a canvas or fitted pair that uses whole multiples of the reduced source ratio.

Frequently asked questions

Does the calculator resize my image file?

It calculates a suggested width and height. Apply the dimensions in your editor if you want to produce a new image file.

What happens when the image and canvas have the same ratio?

The image can meet both bounds at once when the enlargement setting allows the required scale. If enlargement is disabled and the image is smaller, there can be remaining space on both axes.

Do the leftover pixels include both sides?

The detail gives the total unused dimension. Divide by two when placing the fitted image in the center.

Why is the ratio reported separately from the result size?

The ratio describes the source shape. The fitted size describes one scaled placement inside the chosen target dimensions.