Lessons / Software

GIMP Perspective Tool: Fixing, Warping and Drawing on a Grid

How to use the GIMP perspective tool (Shift+P): straighten a leaning building with Corrective, put an image on a wall, Perspective Clone, and get a grid in.

The GIMP perspective tool is a four-corner transform, and once you know its one important option (Direction) it handles the two jobs people come to it for: straightening a photo that leans, and putting a flat picture onto a receding surface. This guide covers both, the Perspective Clone tool that shares the same idea, and the thing GIMP does not have, a perspective grid for drawing, along with the two ways to get one. It applies to GIMP 3.0 and 2.10; the GIMP manual page for the Perspective tool has the full option list.

Definition

Perspective transform is a mapping that moves the four corners of a layer to four new positions and stretches everything between them to match, the same mathematics as a camera looking at a flat plane from an angle. Move the corners outward at the top and a rectangle becomes a wall seen from below; do it in reverse and a leaning building stands up straight.

Where the tool is and what the options mean

Press Shift+P, or choose Tools → Transform Tools → Perspective. Click the image and a frame with four corner handles appears, with a small dialog showing the transform matrix. Drag a corner to move it; the centre circle moves the whole frame. Press Transform in the dialog (or Enter) to apply, Reset to start again.

The tool options that matter:

Transform — what is affected: the layer, the selection, the path or the whole image. Layer is the usual choice; Image transforms every layer at once.

DirectionNormal (Forward) applies the shape you draw; Corrective (Backward) removes it. This one option is the difference between the two workflows below.

Interpolation — how pixels are resampled. Cubic or NoHalo for photos; None only for pixel art.

Clipping — Adjust lets the layer grow to hold the transformed result; Clip cuts it to the old layer size; Crop to result and Crop with aspect trim to the largest rectangle. Adjust is safest; crop afterwards by hand.

Show image preview and Guides — the preview shows the result live; Guides overlays a grid (choose Number of lines or Line spacing) on the frame, which is what you line up against the image's edges. Turn Guides on for correction work.

Constrain handles (Shift) keeps a handle moving along the frame's edge or diagonal; Around center (Ctrl) moves the opposite handle symmetrically. Readjust resets the handles to a square without undoing the transform, so a second adjustment starts from a clean frame.

Straightening a building (Corrective)

A level two-point grid with vertical edges beside a tilted three-point grid whose verticals converge upward
What a tilted camera does to verticals: the left is what you want, the right is what the photo has. Rendered with the grid tools.

A building whose sides lean inward was photographed with the camera tilted up. Fix lens distortion first if the edges are curved rather than straight (Filters → Distort → Lens Distortion), and level the horizon if the whole image is rotated (the Rotate tool, or the Measure tool's Straighten button). Then:

  1. Press Shift+P. In the tool options set Direction: Corrective (Backward), Guides to a grid of 10 or so lines, and Clipping: Adjust.
  2. Click the image. Drag the four corner handles so the frame's edges run along the building's edges: the two side handles up the leaning verticals, the top along the roofline, the bottom along the ground floor. Use the guide grid to check windows and floors line up with the grid lines. Zoom in for the corners; a few pixels of error at a corner becomes a visible lean across the whole façade.
  3. Press Transform. GIMP maps the frame you drew back to a rectangle and the building comes with it.
  4. The result is taller and narrower than the original in the corrected region and has transparent wedges at the edges. Crop them out (Image → Crop to Content trims to the layer, or use the Crop tool), or fill with the Clone or Heal tool.

If the building now looks too tall, it is because a tilted camera also foreshortens the façade. Run the Scale tool with the chain unlinked and reduce the height by 5–15% until windows look square, or use the Unified Transform tool (Shift+T), which combines scale, perspective and rotation in one pass with less resampling.

For a whiteboard, a page or a painting photographed at an angle, the same steps apply with the frame on the four corners of the rectangle. After Transform, Image → Canvas Size or Scale Image to the known proportions (A4 is 1:1.414) so text does not end up subtly wide.

Putting an image onto a surface (Normal)

To place a poster on a wall, a label on a box or a screen into a photographed monitor, paste the flat image as a new layer above the photo, then transform that layer with Direction: Normal (Forward). Drag its four corners onto the four corners of the surface in the photo. Show image preview lets you see the fit before committing; Transform applies it. Set the layer's mode to Multiply or lower its opacity for a print on a textured wall, and add a small Gaussian blur if the photo is softer than the pasted image.

Two things make this convincing. The corners must land exactly on the surface's corners, so zoom in. And the pasted image needs the same perspective as the surface, which the four-corner mapping supplies automatically for a flat rectangle; a surface that is not flat (a curved bottle, a folded flag) needs the Cage or Warp Transform tools instead.

The perspective warp tool on this site does the same four-corner placement in the browser, and the perspective correction tool does the corrective version, if you need the fix without opening GIMP.

Perspective Clone

Tools → Paint Tools → Perspective Clone is the Clone tool that understands a receding plane. In its options choose Modify Perspective, and drag the four corners of a frame to lie along the surface (the mortar lines of a brick wall, the joints of a tiled floor). Switch to Perspective Clone, Ctrl-click a source point on the surface, and paint: the cloned pixels are scaled and skewed as they move along the plane, so a patch cloned from the near end of a wall fits at the far end. It is the tool for removing a sign from a wall or extending a floor past the frame edge.

Drawing a perspective grid in GIMP

GIMP has no vanishing-point or perspective-grid feature for drawing: its guides are straight horizontals and verticals dragged from the rulers, and its grid (View → Show Grid) is flat. There are two ways to draw on a perspective grid anyway.

Download SVG, then File → Open as Layers in GIMP with Import paths ticked: the grid lines become paths.open in the full tool →

As a layer. Set up the 2-point grid (or 1-point, 3-point or curvilinear) at your lens, rotation and camera height, download a transparent PNG at 2× and use File → Open as Layers. Lower its opacity, lock it, and draw on a layer above. Click, then Shift-click, with any paint tool to draw a straight line between two points; that is GIMP's ruler.

As paths. Download the SVG instead and open it with File → Open as Layers; in the import dialog tick Import paths. The grid arrives both as a rendered layer and as paths in the Paths dialog. Paths can be stroked at any width (Edit → Stroke Path), hidden, and used with the Paths tool to pick vanishing-point lines exactly, which is the closest GIMP gets to snapping to a grid.

To match a photo, run it through the vanishing point finder first, which reads the horizon, lens and tilt and opens the matching grid.

Common problems

The handles won't move where I want. Constrain handles is on, or Shift is held. Release it. If handles are off-screen, zoom out; the frame extends past the canvas when Clipping is Adjust.

The transform is jagged or soft. Interpolation is None or the layer is small. Use Cubic or NoHalo and work at full size.

Corrective made it worse. The frame was drawn as the desired result rather than as the existing distortion. In Corrective mode, trace what is there; in Normal mode, draw what you want.

Part of the image disappeared. Clipping was Clip or Crop. Undo, set Adjust, transform again.

Nothing happens on Transform. The active drawable is not what you expect: a layer mask, a channel or a group is selected. Click the layer in the Layers dialog.

Related

Photoshop's perspective tools · fix perspective in Affinity · Krita's perspective assistants · perspective correction online

Questions

Where is the perspective tool in GIMP?

Tools → Transform Tools → Perspective, or press Shift+P. In the toolbox it is grouped with the other transform tools (Unified Transform, Rotate, Scale, Shear), so long-press or right-click the group icon if you do not see it.

How do I straighten a building in GIMP?

Select the Perspective tool, set Direction to Corrective (Backward) in the tool options, and drag the four handles so the frame's edges follow the building's leaning edges. Press Transform: GIMP pulls the frame back to a rectangle and the building straightens with it. Crop the transparent wedges afterwards.

What is the difference between Normal and Corrective in GIMP's perspective tool?

Normal (Forward) applies the distortion you draw: drag the frame and the image follows. Corrective (Backward) does the reverse: you trace the distortion that is already in the image, and GIMP removes it. Use Normal to put something into perspective and Corrective to take perspective out.

Does GIMP have a perspective grid or vanishing point tool?

No. GIMP has guides (straight lines you drag from the rulers) and the Perspective tool's optional on-canvas grid, but nothing that draws converging lines from a vanishing point. Import a grid as a layer, or open an SVG grid with Import paths on so the lines become paths you can stroke.

What is GIMP's Perspective Clone tool for?

Cloning along a receding surface, such as repairing a brick wall or extending a tiled floor. In Modify Perspective mode you set a four-corner plane; switch to Perspective Clone, Ctrl-click a source and paint: the clone is scaled and skewed to the plane as it recedes.

Why is my perspective transform blurry in GIMP?

Stretching resamples pixels. Work at full resolution, set Interpolation to Cubic or NoHalo, transform once rather than in several passes, and sharpen lightly at the end. Pulling corners far outward enlarges that region and cannot recover detail that was never there.