Auto-crop in PIL?
Tyler Eaves
tyler at tylereaves.com
Thu Oct 30 12:49:05 EST 2003
More information about the Python-list mailing list
Thu Oct 30 12:49:05 EST 2003
- Previous message (by thread): Auto-crop in PIL?
- Next message (by thread): Auto-crop in PIL?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, 30 Oct 2003 14:42:36 +0000, Kevin Smith wrote: > Is there a way to "auto-crop" an image in PIL? I have some PNG images > with white backgrounds that I want cropped to show only the non-white > portion in the center, but I don't see how I can do this. Disclaimer: I've never used PIL, so I'm not familiar with it's interface. Here's a basic algo: >From each of the four directions, scan towards the center until you encouter a non-white pixel. Then use those 4 intercepts as your corners. That is, the image is in the rectangle (left non-white, top non-white), (right non-white, top non-white), (right non-white, bottom non-white), (left non-white, bottom non-white)
- Previous message (by thread): Auto-crop in PIL?
- Next message (by thread): Auto-crop in PIL?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list