[Gllug] Image cropping from a script
Tom Weissmann
trmsw at yahoo.co.uk
Wed Jul 4 18:25:30 UTC 2007
- Tethys wrote:
> On 7/4/07, Fred Youhanaie <fly at anydata.co.uk> wrote:
>
>> The smallest rectangle is still going to be 1x1 pixel, but if you meant
>> largest rectangle, I think the GIMP autocrop might help you here, below
>> is an extract from the manual:
>
> No, I meant smallest, which is definitely not a single pixel. GIMP's
> autocrop is not what I want, as it looks for pixels of the same colour
> in the border, where I need it to look for pixels of the same colour
> in the remaining image.
It might be useful if you were able to change every pixel you didn't
want into the same "border" colour, acrop as much of that border as
possible with autocrop, and then restore the colour information you just
removed (from a duplicate layer).
ImageMagick (well, RMagick) lets you get the bounding box of an image,
which is the rectangle that encloses all the pixels not in the border
color.
You could create a copy of the image, perform some operation [*] on it
to change all colours that aren't the colour you want into a border
colour, get the bounding box of _that_ and use the coordinates to crop
the original.
[*] what this operation is, I don't know, but there must be a way...
Regards,
Tom SW
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list