美文网首页
python Pillow crop 裁剪照片

python Pillow crop 裁剪照片

作者: 虚心的锄头 | 来源:发表于2021-06-09 09:19 被阅读0次

原图


ico.png
from PIL import Image
import os
filename = ''
iconame = os.path.join(filename, 'ico.png')
img = Image.open(iconame)
_width, _height = img.size 
crop = (55, 0, _width, _height)
cropped = img.crop(crop)  # (left, upper, right, lower)
cropped.save('new_ico.png')

结果


new_ico.png

相关文章

网友评论

      本文标题:python Pillow crop 裁剪照片

      本文链接:https://www.haomeiwen.com/subject/ougseltx.html