Guide lines or four corners · homography warp · crop to fill · full-resolution export

Fix Photo Perspective

Buildings that lean inward, a horizon that tilts, a sign photographed from the side: drag guide lines along edges that should be vertical or horizontal and the picture is warped until they are, or mark four corners and flatten what they enclose. The preview is a reduced copy; the download is warped from the full-size picture.

Picture

A building, a street, a whiteboard or a framed print

Drop a photo here, paste, or click to choose

PNG, JPG, WEBP, GIF or BMP, up to 25 MB. Pictures over 5000 px on the long side are scaled down when opened.

Fix Photo Perspective

Operator: Abdulla Al Fahad. How tools are built and checked

Point a camera up at a building from the pavement and its two vertical edges stop being parallel. In the 4000 x 3000 px photo of the worked example below, one edge leans to 104.6 degrees and the other to 75.5, a spread of 29.1 degrees, while the rooflines drift 0.8 degrees apart. Drag a guide along each edge and the page finds where each family of lines would meet, then warps the picture so both families run perfectly vertical and perfectly horizontal.

A second method needs no edges at all: mark the four corners of something you know is rectangular, such as a poster, a door or a whiteboard, and it is flattened to a straight-on view at the shape you choose.

Key features

  • Up to 8 vertical and 8 horizontal guides, each with draggable end points and extended across the picture
  • Vanishing points from a weighted least-squares fit, then a projective warp, rotation and shear that make both families axis-aligned
  • One guide of a kind only rotates the picture; two or more also remove its convergence
  • Crop to fill, the largest rectangle with the picture's own shape that fits inside the warp, or keep the whole warped picture with transparent corners
  • Extra rotation of up to 10 degrees in 0.1 degree steps, and an optional grid on the result
  • Four-corner flattening with free, square, 3:2, 4:3, 2:3, 3:4 or A-series proportions
  • Full-resolution export as JPG or PNG, up to 24 megapixels, with progress and cancel

Vanishing points, the warp and the crop

A photo over 5000 px on the long side is scaled down when it is opened, and an animated GIF is read as its first frame. The two canvases show a copy of at most 900 px, and every guide is stored in coordinates of the full picture, so the preview and the download are the same warp. The download is rendered in row chunks so the page stays responsive, and Cancel stops it between chunks.

A guide is a line through two points; each is converted to a line in homogeneous coordinates and weighted by its length when the vanishing point is solved, so a long edge counts for more than a short one. The picture is worked on in coordinates centred on its middle and divided by its long side, so the maths does not depend on resolution. A single guide, or guides that are already parallel, give no finite vanishing point, so only a rotation is applied. If the guides imply a camera tilt so steep that the picture would fold through the plane of the lens, the page says so instead of producing a smear.

The output is capped at 24 megapixels and 8000 px on the long side, and a result larger than that is reduced and marked as reduced. Transparent corners are kept for PNG; a JPG fills them white. Pixels are sampled bilinearly, with a half-pixel soft edge where the warped picture ends. This is a geometric correction only: it does not know the lens, so barrel distortion in a wide-angle photo stays curved.

How it works

For a vertical family the lines meet at a point v. The page builds a projective map that sends the line through v perpendicular to the direction from the picture's centre to infinity, which turns the converging lines into parallel ones. With both families, the line joining the two vanishing points is the horizon and is sent to infinity; the lines are then rotated until the horizontals lie along the x axis, and sheared until the verticals lie along the y axis. The shear only moves points sideways in proportion to their height, so the picture's proportions are kept.

The crop to fill is found by search. The warped picture is a convex four-sided shape; the page tries rectangles of the picture's own width-to-height ratio centred on a 13 by 13 grid of points, finds the widest one that fits at each centre by bisection, then refines the centre in finer steps around the best, taking the largest one whose four corners lie inside. The four corners of that rectangle are mapped back through the inverse transform, giving the quadrilateral of the original photo that is sampled into the output.

Common use cases

  • An estate agent's exterior shot of a terrace, taken from the pavement: two vertical guides on the end walls and one on a drainpipe, two horizontals on the eaves and the ground floor sill, and Crop to fill gives an upright frontage ready for a listing.
  • A shelf unit photographed from the left: choose the four-corner method, drag the handles to the unit's outer corners, pick 2 : 3 portrait and the result is a straight-on 1872 x 2808 px picture from a 4000 x 3000 original.
  • A whiteboard photographed from a seat at the side of the room: use the four-corner method on the board's outer corners and the A4 landscape shape, and the board comes out square-on and ready to paste into minutes.
  • A seascape with a horizon sloping by a few degrees: one horizontal guide along the waterline is enough to level it, because a single guide only rotates.

How to use this tool

  1. Open a photo, choose Add vertical guide, and click two points along an edge that should be upright, such as a wall corner; repeat on the other side of the picture.
  2. Add two horizontal guides along a roofline and a sill, then check the grid on the result and nudge Extra rotation if you judged a horizon by eye.
  3. Read the line under Check and save: it gives the rotation, how far your guides lean apart, the result size and how much of the picture the crop keeps.
  4. Pick Crop to fill or Keep the whole picture, choose JPG or PNG and press Download full-size result.

Example

A 4000 x 3000 facade photo with four guides

vertical guides: (1200,300)-(600,2600) and (2800,380)-(3400,2700)
horizontal guides: (1200,300)-(2800,380) and (600,2600)-(3400,2700)
Crop to fill

Result shown beside the preview

rotation -2.45°; vertical guides lean apart by 29.1°, horizontal guides by 0.8°
result 3543 x 2657 px, keeping 78.5% of the picture's area
Keep the whole picture instead: 6212 x 3724 px with transparent corners
after the warp both guide families measure exactly 90° and 0°

Tips for best results

  • Spread the guides. Two verticals at opposite sides of the picture fix the convergence far better than two close together, and an edge that spans most of the height beats a short one.
  • Look at the convergence figure in the result line. When a corner photo of a room reports vertical guides leaning apart by under 2 degrees, adding perspective correction gains little and rotation alone is enough.
  • Choose Keep the whole picture when something near the edge must not be cropped away, then crop it yourself; the transparent corners show exactly how much the warp stretched.

Common pitfalls

A correction only straightens what you point at. Fully removing the convergence of a tall building makes it look slightly too narrow at the top, as any upright tool does, because the camera really did see it that way. If the picture looks stretched tall or squat, the guides probably mix edges that are not truly vertical or horizontal in the scene, such as a leaning tower or a sloping street.

Common errors and how to fix them

These guides imply a camera tilt too extreme to correct
Two guides probably sit on edges that do not run the way you labelled them, for example a vertical guide drawn on a horizontal edge. Remove the odd guide and check the colours: emerald lines should be upright edges, blue lines level ones.
The four corners cross each other or sit on one line
The handles must go around the shape in order, top-left, top-right, bottom-right, bottom-left. Drag a handle that has crossed over back to its own corner, or press Reset the corners.