Mukund

Mukund's Blog

Archive for December, 2006

Auto-clipping after transformations in GIMP

Saturday, December 23rd, 2006

Following my last post on this subject where only the raw algorithm for finding the largest rectangle was completed, the UI and PDB changes for using this functionality are also done now (and several edge cases were fixed in the process). I’ll commit it once it gets some external testing from some of our esteemed customers ;). All affine transformations now present a combo box with clipping modes:

GIMP toolbox

GIMP toolbox

Here is an example with rotation, using the excellent Wilber splash draft by Paul Davey and Jimmac (still no window decoration in the screenshots):

Wilber before

Wilber before

Wilber during

Wilber during

Wilber after

Wilber after

Largest rectangle in a polygon

Saturday, December 16th, 2006

GIMP now has working code to find the largest rectangle in the quadrilateral (aligned with the XY axes) which results after a transform (rotate, perspective, etc.). As an example, when a user rotates an image, she can decide to automatically crop the image to an rectangle aligned with the canvas so that no transparent areas are introduced (an often used use-case which is used usually often ;) ). A UI for using this feature will be available soon.

The shapes below are from a GTK+ test program which uses Cairo to draw, but when I took screenshots, the window decoration disappeared (maybe because of desktop effects). The black polygon is the transformed quadrilateral and the green rectangle is the computed result. The function also accepts an aspect ratio to provide a properly sized rectangle.