How to Straighten a Photo in GIMP

Three methods for fixing tilted horizons and converging verticals in GIMP 3.x, plus Script-Fu automation for batch processing a folder of images.

Beginner ~25 min read Updated May 2026
3
Straightening methods
< 1 min
Measure Tool auto-angle
Script-Fu
Batch process entire folders

Why Horizons Go Crooked

A tilted horizon is among the most common technical flaws in amateur photography and one that the eye detects immediately - Even in viewers who cannot articulate why an image looks "off". The human visual system has a strong expectation that the sea, the ground, or any flat reference line should be level, calibrated by our inner ear and years of experience interpreting scenes. Even a one-degree tilt is enough to create unease.

Several factors cause tilted horizons. Handheld shooting without a level or electronic horizon guide is the most common. Camera shake in the act of pressing the shutter can introduce a small twist. Shooting with a wide-angle lens while tilted slightly forward or back causes both horizontal tilt and perspective distortion. Even mounted shots on a tripod can be skewed if the tripod head is not precisely levelled. Scanning physical prints introduces additional variability from misalignment on the scanner bed.

There is also a second category of problem that looks like a tilted horizon but is actually perspective distortion. When photographing a tall building from the base, the vertical lines converge toward the top - The classic "keystoning" or "converging verticals" problem. This requires the Perspective tool rather than simple rotation and is covered in Method 3.

Check with a fresh eye: When reviewing your own photos, it is easy to overlook a tilted horizon because your brain adapts to what it sees. After straightening in GIMP, view the image at reduced zoom (Shift+E to fit the window), then look away for a few seconds and look back. Your eye will immediately flag any remaining tilt.

Method 1: Rotate Tool (Shift+R) with a Guide

The Rotate tool is the most hands-on method and gives direct visual feedback. You rotate the layer interactively until the horizon looks level. It is best for images where there is a strong visual reference line (horizon, tabletop, floor) and you want to judge the straightness by eye while rotating.

Step-by-Step Using a Horizontal Guide

  1. 1
    Enable rulers and add a guide: Make sure rulers are visible (View → Show Rulers or Shift+Ctrl+R). Click on the top horizontal ruler and drag down into the canvas to create a horizontal guide line. Position it at roughly the height of the horizon in your image.
  2. 2
    Activate the Rotate tool: Press Shift+R. In Tool Options, ensure the Transform option is set to "Layer" (not "Selection" or "Path").
  3. 3
    Click on the canvas: A rotation dialog appears. You can see the Angle field in the dialog - Type a value directly if you already know the angle, or drag the layer to rotate it interactively.
  4. 4
    Align the horizon to the guide: Rotate until the horizon in the image runs parallel to the blue guide line you dragged down from the ruler. Use small adjustments - Rotate left by clicking and dragging left on the canvas, right by dragging right.
  5. 5
    Click Rotate to apply: In the Rotate dialog, click the Rotate button. GIMP applies the rotation. White triangular corners will appear where the rotated image does not fill the original canvas boundaries - These need to be cropped away.
Interpolation quality: In the Rotate Tool Options, set Interpolation to "Cubic" or "Sinc (Lanczos3)" for the best quality when rotating. "None" (nearest neighbour) is faster but produces jagged edges. For photo work always use Cubic or Lanczos.

Method 2: Measure Tool to Auto-Rotate

The Measure tool is the fastest and most precise way to straighten a horizon in GIMP. Rather than eyeballing the rotation by hand, you draw a line along the horizon with the Measure tool and GIMP calculates the exact angle required to make that line horizontal. Then a single menu command applies the correction automatically. This entire workflow takes under one minute.

Step-by-Step Auto-Rotate Workflow

  1. 1
    Activate the Measure tool: Press Shift+M. The cursor changes to a ruler icon.
  2. 2
    Draw a line along the horizon: Click on one end of the horizon line and drag to the other end. Choose two points as far apart as possible and on the same continuous level surface - This maximises accuracy. A measurement line with angle and distance readout appears in the status bar at the bottom of the GIMP window.
  3. 3
    Apply the rotation via the Transform menu: In GIMP 3.x, go to Image → Transform → Rotate by Angle. GIMP pre-fills the angle field with the correction angle calculated from your Measure tool line. The value is the amount the image needs to be rotated to make the measured line horizontal.
  4. 4
    Confirm the rotation: The pre-filled angle is typically correct. Click Rotate (or OK, depending on your GIMP version). The image rotates precisely to level the horizon.
  5. 5
    Crop the white corners: Use the Crop tool to remove the white triangular areas at the corners (see the "Crop After Rotation" section below).
The Measure tool also shows the angle in Tool Options: After drawing the measure line, look at the Angle value in the Tool Options panel. This is the most accurate readout. A value like -1.7 degrees means the right side of the horizon is 1.7 degrees lower than the left, and the image needs to be rotated 1.7 degrees clockwise to correct it.

Method 3: Perspective Tool for Converging Verticals

The Perspective tool addresses a different problem from simple rotation: keystoning or converging verticals, where vertical lines in the image (building edges, doorframes, lamp posts) appear to lean toward each other or diverge because the camera was tilted up or down during shooting. This is extremely common in architectural and real-estate photography and cannot be fixed with rotation alone.

The Perspective tool distorts the image non-uniformly - It lets you move each corner of the image independently, effectively "untrapezing" a keystone-distorted image back to a rectangle.

Step-by-Step Perspective Correction

  1. 1
    Add vertical guides: Drag two guides from the left ruler to the canvas. Position them along vertical elements in the image that should be perfectly vertical (building edges, door frames). You will use these as a reference.
  2. 2
    Activate the Perspective tool: Press Shift+P. Click on the image. A grid overlay with drag handles at each corner appears.
  3. 3
    Drag the top corners outward: For a building where vertical lines converge at the top (the most common case), drag the top-left corner to the left and the top-right corner to the right. This widens the top of the image, counteracting the inward convergence of the building's edges.
  4. 4
    Align to the guides: Move the corner handles until the building's vertical edges run parallel to the vertical guide lines you placed earlier. The grid overlay helps judge when the verticals are straight.
  5. 5
    Apply and crop: Click Transform (or press Enter). The perspective correction distorts the canvas into a trapezoid shape. Crop aggressively to remove the empty areas at the corners - You will lose some of the image, which is unavoidable with this type of correction.
Perspective correction trades field of view for accuracy: Every degree of perspective correction sacrifices some of the original image content at the edges. For extreme corrections (shooting at a very steep upward angle), you may lose 15–30% of the image height. Shoot from a greater distance or at a higher position to reduce the correction needed in post.

Crop After Rotation (Removing White Corners)

Whenever you rotate an image in GIMP, the corners that were outside the original canvas boundary become empty - GIMP fills them with the background colour (usually white or transparency). Before exporting, these areas must be cropped away.

There are two cropping strategies: crop to a rectangle that fits entirely within the rotated image (maximum crop), or crop to a specific aspect ratio that removes the corners while keeping as much image as possible.

Crop to Remove Corners

  1. After rotating, go to Image → Flatten Image. This merges the rotated layer with the white background so the canvas now has solid white corners.
  2. Activate the Crop tool (Shift+C).
  3. In Tool Options, enable "Fixed" and set it to "Aspect Ratio" if you want to maintain a specific aspect ratio (e.g., 3:2 for standard camera output), or leave it unconstrained for maximum coverage.
  4. Draw a crop rectangle that excludes all white corner areas. The corners of the crop box must sit within the rotated image boundary.
  5. Press Enter to apply the crop.

Auto-Crop After Rotation

GIMP 3.x offers a convenient automatic option: after rotating, go to Image → Autocrop Image. This command finds the largest rectangle that fits within the rotated image content and crops to it automatically. The result is always slightly smaller than the original but removes all empty corners in one step.

The geometry of corner cropping: For a 2-degree rotation, you lose roughly 3.5% of the image dimensions on each side to cropping. For 5 degrees you lose about 8.7%. If you frequently have large horizon errors, shoot wider than you need to compensate for the crop loss.

Script-Fu Automation for Batch Straightening

If you have a folder of images that all need the same rotation correction - For example, a scanning batch where every scan is 1.5 degrees off due to a misaligned scanner bed - You can automate the correction with a Script-Fu batch script. This processes all images in a folder, applies the rotation, autocropping, and saves as PNG or JPEG without any manual intervention.

; Script-Fu: rotate all JPEGs in a folder by a fixed angle

(let* ((folder "/path/to/your/images/")
       (files (cadr (file-glob (string-append folder "*.jpg") 1))))
  (for-each
    (lambda (filename)
      (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
             (drawable (car (gimp-image-get-active-drawable image))))
        ; Rotate by 1.5 degrees clockwise (negative = clockwise in GIMP)
        (gimp-item-transform-rotate-simple drawable -0.026180 TRUE 0 0)
        (gimp-image-flatten image)
        ; Autocrop to remove white corners
        (plug-in-autocrop RUN-NONINTERACTIVE image drawable)
        ; Save as PNG
        (file-png-save RUN-NONINTERACTIVE image
          (car (gimp-image-get-active-drawable image))
          (string-append folder "straightened_"
            (car (last (strbreakup filename "/"))))
          filename 0 9 1 1 1 1 1)
        (gimp-image-delete image)))
    (vector->list files)))

To run this script: open Filters → Script-Fu → Console, paste the script (with your actual folder path replacing /path/to/your/images/ and your actual rotation angle in radians), and press Run. GIMP will process every JPEG in the folder and save the corrected versions with a "straightened_" prefix.

Note that the rotation angle in Script-Fu is in radians, not degrees. To convert: radians = degrees * (pi / 180). Common values: 1 degree = 0.01745 rad, 1.5 degrees = 0.02618 rad, 2 degrees = 0.03491 rad.

Using the Grid Overlay (View → Show Grid)

GIMP's built-in grid overlay is an underused but extremely helpful tool for straightening. The grid displays a regular pattern of horizontal and vertical lines across the entire canvas, making it immediately obvious when the horizon in a photo does not align with the grid lines.

Setting Up and Using the Grid

  1. Enable the grid: View → Show Grid (or press Shift+Ctrl+E). A regular grid of lines appears over the image.
  2. Configure grid spacing: Edit → Preferences → Default Grid. Set Width and Height to something proportional to your image - For a 3000px wide image, a 300px grid gives 10 divisions across.
  3. Rotate the image until a prominent horizontal element (the horizon, a tabletop, a windowsill) runs precisely along one of the grid lines.
  4. Hide the grid when done: View → Show Grid again to toggle it off.
  5. Enable "Snap to Grid" (View → Snap to Grid) if you want the Crop tool to snap to grid intersections when cropping after rotation.
Grid vs. Guides: The grid applies a regular pattern across the whole canvas and is ideal for general level-checking. Guides (the blue lines dragged from rulers) are more flexible - You can position each one precisely at any location and angle that matches a specific element in your photo. For precision straightening, guides along the actual horizon are more useful than the regular grid.

Saving the Straightened Image

After straightening and cropping, export the final image in the appropriate format. The choice of format depends on the intended use:

JPEG

  • Best for photographs destined for the web, social media, or email
  • File → Export As, filename ending in .jpg
  • Quality 85–92 for web; 95–100 for print
  • Does not support transparency

PNG

  • Best when lossless quality is needed or transparency must be preserved
  • File → Export As, filename ending in .png
  • Compression 6–9 (always lossless)
  • Larger files than JPEG for photographic content

XCF (GIMP Native)

  • Save your working file for future editing
  • File → Save As (not Export)
  • Retains layers, guides, and history
  • Not suitable for sharing or publishing
"Overwrite" vs. "Export As": File → Overwrite saves directly over the original file in its original format. File → Export As opens a dialog letting you choose a new filename, location, and format. For non-destructive work, always use Export As and choose a new filename so the original is preserved.

Rotation Methods Compared

Method Accuracy Speed Best Use Case Keyboard Shortcut
Rotate Tool with Guide Medium (visual judgement) Medium - 2–3 min When you want visual control and a strong horizon reference Shift+R
Measure Tool + Auto-Rotate High (mathematical precision) Fast - Under 1 min Fastest accurate method for any image with a detectable horizontal line Shift+M
Perspective Tool High for keystoning Slow - 5–10 min Architecture and buildings with converging vertical lines Shift+P
Script-Fu Batch High (fixed known angle) Very Fast for batches Scanning batches or series with consistent, known tilt angle N/A (console)

Common Horizon Error Angles in Amateur Photography

Distribution of tilt errors observed in a sample of 1,000 handheld landscape shots. Most errors fall in the 1–3 degree range, well within the Measure Tool's easy correction capability.