You're right, I haven't read your question properly... I am not sure that 
autocrop exists in pil. Maybe somebody with more experience can shed some 
light.  

Sent from my iPhone

On Jun 9, 2009, at 12:10 PM, "Nils Wagner" <nwag...@iam.uni-stuttgart.de> wrote:

On Tue, 9 Jun 2009 11:31:19 -0700 (PDT)
Anton Vasilescu <vasilescu_an...@yahoo.com> wrote:
I wasn't able to find one in Matplotlib but you can use PIL library for all the 
imaging work. Really easy to use. Here is the webpage for it: 
http://www.pythonware.com/products/pil/index.htm
Anton
Hi Anton,

Thank you for your prompt reply.
I am aware of PIL.
However I didn't find an autocrop function within PIL.

Cheers,
                  Nils

from PIL import Image
im = Image.open('test.png')
#
# Calculates the bounding box of the non-zero regions in the image.
# The bounding box is returned as a 4-tuple defining
# the left, upper, right, and lower pixel coordinate.
# If the image is completely empty, this method returns None.
#
print im.getbbox()

print im.size
#
# Returns a rectangular region from the current image.
# The box is a 4-tuple defining the left, upper, right, and lower
#
box = (100, 100, 800, 800)
region = im.crop(box)
region.show()

It would be nice to compute the box automatically.
Any idea ?





      

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to