Straighten and Crop

Update 10.6.2011 - the new version of the Straighten and Crop script (attached) will use the Python version of Post Rotate Crop if this is installed; otherwise it will use the Script-Fu version of the script. (The Python version of Post Rotate Crop is very much faster than the Script-Fu version)

A script that provides an easy method for straightening pictures and then, optionally cropping them to remove the resulting transparent areas.

The centre of rotation can be specified as can the type of cropping required.

The cropping can be performed by the GIMP rotate function but this can have unpredictable results. The Post Rotate Crop script provides more options and seems more reliable (let me know should you find a problem with it)

This version of Straighten and Crop uses the revised interface to the Post Rotate Crop script, including the option to select the aspect ratio of the cropped area.

The attached zip file includes the script and a text file of notes on its use.

AttachmentSize
StraightenAndCrop.zip6.08 KB

Comments

Scale to original size

I love this script for tweaking photos, but always end up scaling images back to original size which I like to do for consistency. I added a checkbox and related functionality to do this. It was not difficult but let me know if you want to incorporate it and I will send it to you.

Scale to original size

That sounds like a good addition to the script. If you send me your version I will update the one posted here.

Interpolation method for rotation

I have now discovered that the problems reported by payasam with my Post Rotate Crop script are actually due to their having the interpolation option for the rotate tool set to Sinc (Lanczos3). Using this interpolation method the corner pixels of the rotated image are not guaranteed to be totally transparent (have an alpha value of 0) even when the image is rotated about its centre. For instance when a 400 x 600 pixel image is rotated 0.7 degrees (clockwise) using the Lanczos3 interpolation algorithm the alpha values for pixels (0,0), (0,1), (0,2) and (0,3) are 2, 1, 0, 96 respectively; when Cubic interpolation is used the alpha values are 0, 0, 0, 80.

To me this indicates a bug in the Lanczos3 interpolation algorithm or the way in which the rotate tool uses the Lanczos3 algorithm.

I would therefore suggest that when using this Straighten and Crop script the interpolation type parameter should be set to Cubic and not to Sinc (Lanczos3).

Updated version

I have updated the attachment. The script closes its undo group before calling Post Rotate Crop so that GIMP doesn't report an inconsistency if Post Rotate Crop has to report an error. Also limited the specified aspect ratio height and width to minimum values of 1.

needs postrotatecrop.scm

Sorry if I'm just being a noob, but it wasn't obvious to me that this script depends upon another script being present. I got a "can't find postrotatecrop.scm" error the first time I ran this script.

It can be found at: http://registry.gimp.org/node/18820

Other than that, an easy to use and useful script. Thanks!

Syndicate content