[Image-SIG] Trim borders?

Matt Howell bigmattyh at gmail.com
Tue Jul 15 20:24:01 CEST 2008

Is there a straightforward way to trim off the borders of an image, using

ImageMagick has a similar function called trim(), that looks at the 4
corner-pixels of the image, figures out what color the border is, and then
trims out rows and columns from the image's edges until it reaches a portion
of the image that doesn't match the border color.  (I believe the function
also has a variable tolerance setting, where you can specify a range of
color where the matched border color would be considered to be a part of the

I see that there's a crop() function in PIL, but as you can see, the key to
the trim() function is that the library automatically figures out where the
border is and crops the image accordingly.

Thanks for the help.

Matt Howell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/image-sig/attachments/20080715/459d6ad1/attachment.htm>

More information about the Image-SIG mailing list