[Gllug] Image cropping from a script
Salim Virani
me at salimvirani.com
Wed Jul 4 18:17:30 UTC 2007
On 4 Jul 2007, at 18:56, - 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.
>
> Tet
>
I'm not too familiar with how scriptable GIMP is, but could one write
a script that does the following?
1) Duplicates the image, or creates a new layer as a duplicate.
2) Selects only the desired colour.
3) Removes all other pixels, replacing them with transparent.
4) Use autocrop to find the cropping parameters for the duplicate,
which now contains only the desired colour and transparent.
5) Apply those cropping parameters to the original image, or just
apply them to both layers and then removes the top layer.
In Photoshop, you can set that up as an action.
ImageMagick also has a autocrop, crop and layer functions, so maybe
that's worth a look too.
http://www.imagemagick.org/script/command-line-options.php
Sal
> --
> Perl is like vise grips. You can do anything with it but it is the
> wrong tool for every job. -- Bruce Eckel
> --
> Gllug mailing list - Gllug at gllug.org.uk
> http://lists.gllug.org.uk/mailman/listinfo/gllug
>
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list