You are here

EZ Perspective

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Rate this item!

Turn this:

original image, taken by camera tilted up

…into this:

perspective corrected image, rectilinear, correct proportions

…using the “EZ Perspective” filter, now available at Filters → Distorts → EZ Perspective… – get now!

Particularly well-suited for the needs of photographers seeking to correct perspective, but flexible enough to be used by all those wishing to add perspective to an otherwise flat scene.

Demo video by Mahvin.

Installation :: Usage :: Use cases :: Tricks

Future plans :: Similar tools :: Technical details :: Batch processing :: Closing notes


  • Download
  • Unzip the ZIP file to get
  • (maybe necessary) make the .py file executable (on Linux and Mac OS X), via chmod +x (can also do by right-clicking and changing “Properties”)
  • Put in your plug-ins folder, which you can find at File → Preferences → Folders → Plug-Ins
  • Restart Gimp
  • Open a file, and find the filter in Filters → Distorts → EZ Perspective… !


If you’re having trouble:


Some general tutorials on perspective correction: Perspective correction – PanoTools & Perspective Correction In Photoshop – Keystoning.

  • Use up/down to fix vertical lines not being parallel: \/ or /\ and use left/right to fix horizontal lines not being parallel: > or <. (And use rotate to rotate.) To get a feel for this, take photos of a window when tilting up, tilting down, swinging left, swinging right, and rotating clockwise/counter-clockwise, and then correct them.
  • Enter how much to change the angle in each direction, either by using the sliders or by explicitly keying in the angles in the boxes. (If a box is left at 0, the slider value is used.)
  • Easiest is to <TAB> between sliders, and use ←/→ (<LEFT>/<RIGHT>) to adjust each angle in turn: first up/down, then left/right, then rotation. (First make verticals parallel, then horizontals parallel, then rotate so actually vertical and horizontal. You may find tweaking rotation as you go helpful, rather than leaving it for last.)
  • Lacking preview, easiest way to try different angles via undo/redo (Ctrl-Z, Ctrl-Y) and re-run the filter via Ctrl-Shft-F.
  • You may find viewing a grid helpful (View → Show grid).
  • Use “fast” interpolation at first when zeroing in on best angle, then “good” for final version.
  • Oh, and as a technical matter, you’ll want to enter the 35 mm Equivalent Focal Length of the lens used (assuming this is a photograph). If this isn’t right, the perspective will be off (which is visible), and the angle measurements will be incorrect (which is just an interface issue).
  • You may find it convenient to refer to the directions as: up/down – “tilt” or “pitch”; left/right – “swing” or “yaw”; and rotation – “twist” or “roll”.
  • Use after correcting lens distortion (Filters → Distort → Lens Distortion… – barrel distortion, vignetting, lateral chromatic aberration), as these depend on the lens, the shot as taken.
  • Use before cropping, as this changes the shape of the image and you’ll likely want to crop afterwards. (Also, if you’ve cropped, you’ll have to adjust the EFL to compensate for the changed angle of view, and you’d really rather not fuss with that.)
  • In principle you can apply the filter repeatedly, and if you only rotate in one direction, angles are additive (5% + 5% = 10%). In practice this is undesirable and you should use a single transform because the filter interpolates each time it is applied, degrading image quality. More technically, if you rotate in more than one direction, the combined effect is not simply adding the angles, due to interactions between different rotations.

But wait, there’s more!

Actually, there isn’t. This is a specialized tool for easily correcting or changing perspective, just like it says on the tin, and that’s all it does.

Use cases

  • It’s easiest to get perspective right in the field, rather than fixing in post-processing; beyond fixing minor aiming errors, in some cases you cannot get a shot with the right perspective, and thus correction is necessary.
  • Perspective (and rotation) is most visible if there are verticals or horizontals (or, a fortiori, both – rectangles) in the image, most significantly in architecture (buildings, windows, doors), but also in horizons, trees, and people. If there aren’t any boxes in the image, perspective is a relatively subtle scale effect, while if there are boxes, it’s quite visible if an image is square and “plumb” or not.
  • If the subject is not flat (not all on one plane, regardless of whether that plane is parallel to the imaging plane), then changing perspective introduces parallax errors, which is usually undesirable (unless you want a very distorted effect). For example, if you take a shot of a colonnade from the left, the image does not contain the right sides of the columns, so if you change the perspective so it appears that the shot is taken from the front, the apparent “right side” of the columns will actually be the left sides of the columns, wrapped around. In people this is particularly visible in the nose looking very wrong.
  • Perspective is especially a concern when taking photographs of subjects in high places, which requires aiming up – unless you have a ladder, you can’t easily take the shot head-on. On the other hand, many such subjects are more familiar from ground level, so you may wish to retain perspective if you wish to emphasize height – it’s the difference between a shot of the second story looking like it’s from the second story across the street, or from street level. You also may wish to leave a little bit of distortion for buildings – to undercorrect – since it is expected and its absence looks a bit unnatural.
  • Left-right perspective is much less of a concern than up-down perspective – it is familiar and often adds depth and interest to an otherwise flat scene. Thus you may wish to retain it.
  • Minor rotation invariably looks like a mistake and should be corrected, unless you’re going for an intentionally unbalanced feel.
  • A 0.1% up/down or left/right move is quite small – at 10 mm EFL, it is just barely noticeable, and at longer focal lengths, it becomes v. small. (At a 50 mm “normal” length, it’s about 2–3 pixels at the edge of a 3600×2400 image, which is exactly what you’d expect – about a 0.1% move.) Slight tilt or swing is barely noticeable, especially at longer focal lengths (it’s more noticeable with wide-angle lenses), otherwise photography would require superhuman perfection, so don’t sweat it – 10% vs. 11% is not a huge difference.
  • Rotation (twist) is much more noticeable – a 1% error is very visible – and thus you’ll likely want to refine down to 0.1% or 0.2%.


Go Dutch!
Rather than correct, use creatively to get an artistic angle (a “Dutch angle”). If you do this enough, your pictures will look like stills from Battlefield Earth!
Introduce parallax
If the subject is not flat, you will get parallax, which is a rather jarring distortion, but useful if you want a creepy look.
Selective focus
Take a shot with shallow DOF from one angle, then change perspective to another angle, thus having the plane of sharp focus at an angle, achieving Tilt-Shift lens-style effects. Note that if your scene is not all on one plane, you’ll have (possibly severe) parallax. Which you probably don’t want.
Don’t crop
Consider not cropping, or not cropping to rectangular – non-rectangular photos can be a dramatic change from conventional rectangular ones.

Future plans

Main desiderata is to have previewing, which makes tweaking perspective much easier. This requires building the GUI manually, using the full Python gimpplugin library, rather than using the pre-packaged one from gimpfu; it’s do-able, but will take a little time.

Also nice would be to automatically read EFL from Exif, rather than having to key it in. This can’t easily be done currently (Exif information is not available to plug-ins, as far as I can tell), though I plan to hack in something (using exiftool, if available).

Similar tools

“Hmm…,” you say, “but can’t I achieve the same using existing tools, like the (suggestively named) Perspective tool (Tool → Perspective, Shft-P), or perhaps the ‘Map Object – Plane’ filter (Filters → Map → Map Object… → Plane)?”

Well, no.

These are both excellent and powerful tools, but they, and everything else I found discussed under “perspective” (search) do not actually do the desired perspective transforms. If these (or other) tools suit your needs, please use them, but they didn’t satisfy mine, and, if you read on, you, too, may come to share my cravings, and want a new tool. Fortunately, I’ve written one.

Simply, correcting perspective is a very common photographic task – like image rotation – and so you want a specialized tool for it. Further, it has hidden subtleties (elaborated below, in “Technical details”), which mean that a general tool is unlikely to provide the desired behavior.

Turning to the specific tools: the term “perspective tool”, while suggestive, is a misnomer. It is actually a “projective transformation” tool, and can do perspective transforms, but much else besides, and its transforms are almost always not simply changes of perspective. For minor changes, the error is slight, and not terribly objectionable, and many people advocate using this tool (or corresponding ones in other programs) to correct perspective.

Most often advocated is to fix perspective (say, from a shot that is tilted up) by simply stretching the top (e.g., here). The problem is that when you correct perspective, you also need to stretch vertically (or horizontally for left/right perspective), and if you don’t, the result is squat. Here is the result of simply stretching the top, without any vertical stretching (marked as incorrect):

image corrected by stretching top with perspective tool, with incorrect proportions (too squat)

Notice that it is squatter than the correct version; this is most visibly an error as shapes that should be circles are instead ovals.

Further, even if you want to stretch, how much should you stretch? For any angle (and focal length) there’s a single correct amount, mathematically determined, which is difficult to eyeball. Fortunately, we have computers that can do the math for us, as EZ Perspective does. It makes it, if you’ll pardon, “EZ PZ”. Lastly, you may wish a tool where you enter angles, rather than moving corners by mouse, as in the rotation tool. The perspective tool is very powerful and intuitive, but both overkill and a bit fiddly for simply fixing perspective.

“Map Object – Plane” may appear to do the same thing, but it rotates the image, rather than the camera. This filter serves a different purpose – it uses an image as “wallpaper” on some surface. The easiest way to see that it does not do a perspective change is to rotate Y by 30° – the resulting perspective is compressed. In fact, if you rotate by 90°, the plane disappears, while if you actually change perspective by 90° (or, more realistically, by 80–85°), you still have a usable scene, albeit with heavy perspective, corresponding to shooting across (almost parallel to) a surface. More simply, Map Object rotates the image plane so that it is at an angle to the rendering plane, while changing perspective corresponds to projecting an image between parallel planes.

Technical details

For the mathematically-minded… These are all “as far as I can determine” – if there are any errors or you’ve thoughts or references, please feel free to contact me.

Formally, what this tool does is a “camera transform” (or perhaps more properly, an inverse camera transform, followed by a camera transform) – it assumes that the center of the scene is some distance z* away, but the camera is aimed at an angle, and then changes that angle, keeping the center of the scene at the same distance. (Formally, this is PSO(3), acting on the plane given by z=z*.) The distance is why the 35 mm Equivalent Focal Length is necessary: the effect of changing angle depends on the distance – it determines both the relative scale of stretching (e.g., if tilting, how much vertical stretching) and the scale of angles. The easiest way to see this is to use a very short EFL on a photo taken with a longer EFL (e.g., use 10 mm for the example picture; actually taken with 89 mm) – the resulting corrected image will be too squat, and the correction angle keyed in will significantly understate the actual correct. Simply, tilting wide-angle lenses doesn’t stretch as much, and 1° change is a bigger change with a wide-angle lens than with a telephoto lens. As a detail, the EFL here refers to the diagonal EFL (based on diagonal angle of view), which is the most common convention (some use horizontal).

The rotations are done using the zyx convention for Euler angles (or more properly, Tait–Bryan angles), which can be interpeted as “rotate about the extrinsic axes (axes of the scene) in the order x, y, z (up/down tilt, left/right swing, rotation twist), or about the intrinsic axes (axes of the camera) in the order z, y, x.” This seems the most natural order – how would you line up a shot? This is also why applying the filter twice does not simply add angles – it corresponds to z′y′x′zyx (6 rotations in sequence), which is not the same as (z′+z)(y′+y)(x′+x) because the rotation group is not commutative (order of rotations matters).

Note that these camera transforms only have 6 degrees of freedom (it’s the Euclidean space group) – 3 rotations, 3 movements (2 dimensions of shifting the image, 1 dimension of scaling the image). Our concern are the 3 rotations, but the shifts and scaling show up subtly. The projective linear group of the plane, PGL(3) (all transforms that preserve lines, possibly going out to infinity), has 3×3–1 = 8 dimensions; note that the perspective tool has 8 degrees of freedom = 4 points × 2 dimensions/point, and hence is (a top-dimensional subset of) the full projective linear group. Examples of projective transforms that are not perspective are:

  • scaling in one dimension, but not in the other (“inhomogeneous scaling”), and
  • shearing.

It’s really hard to stay on a 6-dimensional space in 8 dimensions (it’s like staying on a 1-dimensional curve in 3 dimensions), which is why output from the perspective tool is almost never an actual perspective transform, and makes formal the fact that it’s hard to eyeball the right height fix. (It’s slightly subtler – different focal lengths add a 7th dimension, so it’s a bit easier to get a transform that’s a perspective transform, but likely for the wrong lens.) Further, only 3 of the dimensions correspond to rotations – the other 3 correspond to shifting and scaling, so unless you’re careful, the transformed image will be larger or smaller, and shifted: staying on a 3-dimensional space in 8 dimensions is trickier yet. For example, the usual “correct perspective by just stretching the top of an image” (say, by 5%) stretches the image horizontally by an average of 2.5%; to avoid stretching you actually would need to stretch the top by 2.5% and shrink the bottom by 2.5%. EZ Perspective corrects for these, as discussed below.

Finally, two subtleties of projective transforms: shifting and scaling. Projective transforms (the matrices of the rotations) move the center of an image, and change the scale. This tool corrects for these by moving the center back to the center and adjusting scale to minimize distortions. This later is a bit tricky – projective transforms change scale differently in the x and y dimensions (and by a different amount in each row and column), so when changing the up/down tilt, we preserve the width of the center row, and correspondingly for left/right swing (preserve center column height). This is generally what you want; can be further customized by specifying where the “center” is, though I’ll add that later.

Further, changing the angle makes the distances that get closer to the camera grow, while those that get further shrink, so the former center of the image is no longer the center of the transformed image (even if it doesn’t move, there’re still more pixels on one side than on the other). This is inevitable, but changes the effect of the composition, and is a subtlety to be aware of.

Batch processing

You can also use EZ Perspective non-interactively, for batch processing, particularly if you have many files with known perspective, or wish to apply automated distortion. Because non-interactive use of Python-Fu plugins can be a little tricky, I’ve written a wrapper function to simplify it, and given an example script. See the below file for how to do this; this will require some manual fiddling on your part. Please:

  • save this file into a directory with images you are working on (do NOT save it into the plugin directory)
  • open the file and read the instructions
  • edit the file and change the filenames and parameters to choose your desired transform

Closing notes

Lastly, the photo (corrected by 40% tilt and 0.3% clockwise rotation, at 89 mm EFL, following pincushion correction) is the former logo of Bowl and Board (hence the shape: a bowl on a board), a delightful housewares store in Cambridge, Mass., now sadly closed.

Hope this tool proves useful – enjoy, and happy Gimping!

Code License: 
GIMP Version: 
Scripting Engine: 


I have Gimp 2.8.0, and it’s “Edit → Preferences → Folders → Plug-Ins” there,
not “File → …”

Hi Espy.
If you have not yet solved your problem (which sounds similar to what I had when I tried to set up Python for Gimp 2.6.10 on Windows XP) you might try the following link that should take you direct to a tutorial that put me on the right track:
I uninstalled everything I had (unsuccessfully) tried to set up and then followed the tutorial step by step before re-installing Gimp and it all came together nicely for me.

Thanks RonBu – that tutorial also worked for me, and I’ve linked it above.

Thanks for a great tool. I've still to explore it's full potential but what I've seen so far indicates that this will have many uses for me.

Thanks for the kind words – if you think of any clever uses, please feel free to share them here!


EZ Perspective should do what you want (assuming I’ve got the math right)!

Sorry to hear about your Python-Fu installation troubles – I can’t help with that, but you may find the help forum useful (you’re more likely to find assistance there).

If you can’t get Python-Fu working, there are other programs with perspective correction (e.g., Hugin, Photoshop) – see Wikipedia article.

Hope these help!

Nils von Barth

Before going in to my installation troubles, let me describe why I need EZ-perspective, just in case I'm on the wrong track here:
What I need EZ-perspective for so badly is that I need to do some true perspective transformations with correct scaling in *both* directions. I'm photographing a rectangular plane, sometimes at an angle, and I need to alter the images such that the image of the plane becomes truly rectangular, with the horizontal surfaces parallel with each other (as well as the vertical), all while keeping the ratio of the side lengths intact. Like trying to photograph a piece of paper at an angle and trying to determine its aspect ratio from the picture. Is it a4 or letter-sized?

Is EZ perspective even what I'm looking for? If so, please help me install Python-fu:

I'm having trouble installing the GIMP with Python support. I'm running GIMP 2.6.10 i686 on Windows 7 with Python2.6, PyGTK, PyGObject, PyCairo (all the latest releases, to the best of my knowledge). I've tried pretty much everything I can think of as well as the things I've read on various tutorials. I tried including the \bin folder from GTK+ into the PATH, I tried installing 'glade,' I've uninstalled, reinstalled, and rebooted more times that I can remember. Does anyone have any tips?

Thanks in advance

did you try to reinstall gimp ,with the custom option AFTER have installed all the python libraries ?


I think it shoul dbe possible to use python-pyexiv2 (at least on linux) to retrieve the lens data from the image - that would make it easier on enter the correct values.
Otherwise a nice script, i plan to add it to the gimp-plugin-registry package in Debian :)



Hi Bernd,

Thanks for advising me of pyexiv2 – I wasn’t aware of it, and it seems the easiest solution (instead of hacking in exiftool). Turns out there are also Windows packages, so hopefully I’ll be able to get something working without too much work.

Including default EFL value will requires manually building the GUI, however, so I’ll work on that after I’ve moved to the manual GUI and done the more pressing task of having live preview!

Nils von Barth


Subscribe to Comments for "EZ Perspective"