Crop a PNG image to its minimum size

前端 未结 6 845
旧巷少年郎
旧巷少年郎 2020-12-16 00:00

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

6条回答
  •  情深已故
    2020-12-16 00:48

    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.

提交回复
热议问题