0
A
回答
1
img = Image.open('your_wonderful_image.png')
nonwhite_positions = [(x,y) for x in range(img.size[0]) for y in range(img.size[1]) if img.getdata()[x+y*img.size[0]] != (255,255,255)]
rect = (min([x for x,y in nonwhite_positions]), min([y for x,y in nonwhite_positions]), max([x for x,y in nonwhite_positions]), max([y for x,y in nonwhite_positions]))
img.crop(rect).save('out.png')
相關問題
- 1. 使用邊框的裁剪圖像
- 2. 在python中使用PIL裁剪圖像
- 3. 使用PIL自動裁剪圖像
- 4. 用python/PIL自動裁剪圖像
- 5. Python的PIL裁剪問題:裁剪圖像的顏色扭曲
- 6. 使用PIL無損圖像裁剪jpeg圖像嗎?
- 7. Python PIL:如何保存裁剪圖像?
- 8. PIL裁剪和粘貼問題:裁剪不會創建裁剪圖像
- 9. WPF剪裁邊框
- 10. ios - 用羽化邊緣裁剪圖像
- 11. 如何裁剪圖像,使用imagemagick圖像中的顏色邊框
- 12. 使用Java裁剪圖像
- 13. 使用openCV裁剪圖像
- 14. 使用css裁剪圖像
- 15. 使用php裁剪圖像
- 16. 使用ImageScience裁剪圖像
- 17. 裁剪圖像使用jQuery
- 18. 使用c裁剪圖像#
- 19. 使用CGImageCreateWithImageInRect裁剪圖像
- 20. 使用CGImageRef裁剪圖像
- 21. 用可設置的中心和Python縮放裁剪圖像PIL
- 22. 裁剪圖像
- 23. 裁剪圖像
- 24. 裁剪圖像
- 25. WinRT中的裁剪/裁剪圖像
- 26. 更改邊界原點+裁剪圖像
- 27. 在屏幕邊緣裁剪圖像html
- 28. 自動裁剪圖像邊界
- 29. 按多邊形區域裁剪圖像
- 30. 用特殊框架裁剪圖像
你可能需要查找「圖像裁剪」爲PIL,看看這個答案:http://stackoverflow.com/a/9983361/532471 – Geekfish 2013-03-18 10:59:12
憑什麼你打算裁剪圖像? ? – pradyunsg 2013-03-18 11:44:47
Geekfish,不,我不知道尖號的邊界。我只想從圖像中剪切數字。 – Nolik 2013-03-18 11:50:38