Alex Rivera | Logout

Crop a PNG image to its minimum size

Asked 2009-12-15T05:52:01.277
24

How to cut off the blank border area of a PNG image and shrink it to its minimum size using Python?

NB: The border size is not a fixed value, but may vary per image.

Edit
Report

1 Answer

0

You can use PIL to find rows and cols of your image that are made up purely of your border color.

Using this information, you can easily determine the extents of the inlaid image.

PIL again will then allow you to crop the image to remove the border.

answered 2009-12-15T06:05:42.693

Your Answer