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" <nwagner@...1052...> wrote:
On Tue, 9 Jun 2009 11:31:19 -0700 (PDT) Anton Vasilescu <vasilescu_anton@...9...> 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
Thank you for your prompt reply.
I am aware of PIL.
However I didn't find an autocrop function within PIL.
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.
# 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)
It would be nice to compute the box automatically.
Any idea ?