How to Calculate and Verify a Square Image Crop
Calculate a centered square, move it around the subject, and verify the crop against the destination mask.
Calculate a centered square, move it around the subject, and verify the crop against the destination mask.
Landscape: side = source height; X = (source width − side) ÷ 2; Y = 0.
Portrait: side = source width; X = 0; Y = (source height − side) ÷ 2.
Round half-pixel results to whole-pixel coordinates and recheck the far edge.
Enter X 400, Y 0, width 1600, and height 1600. Expected output is exactly 1600 × 1600. The left and right exclusions are both 400 pixels; the top and bottom exclusions are zero.
If a face sits near X 1500, move the square right while keeping X + 1600 no greater than 2400. Preview a circular avatar mask separately and leave safe space around hair, text, logos, and corners.
Reject negative X or Y, zero-sized sides, a side above 16384, or a far edge outside the source. For example, X 900 plus width 1600 ends at 2500 and fails on a 2400-pixel source.
Confirm the output summary says 1600 × 1600 and open the downloaded file.
Inspect all four edges for clipped text, faces, or product details.
Test the real square or circular destination mask before deleting nothing from the original.
If delivery requires 512 × 512, resize the accepted square afterward rather than stretching it.
FAQ
Choose a whole-pixel offset on one side and accept a one-pixel imbalance, then verify both far edges remain inside the source.
Unlocking the ratio would distort the scene. A crop deliberately chooses which edge pixels to remove before a proportional resize.
There is no universal number. Preview the destination mask and keep important features away from its boundary.
Further reading
Keep exploring