python PIL库图片裁切
from PIL import Image
def Clipper():
img = Image.open('./001.PNG')
width, height = img.size
print(width,height)
img.show()
box = (500, 500, 2500, 1500)
# 前两个坐标点是左上角坐标
# 后两个坐标点是右下角坐标
# width在前, height在后
region = img.crop(box)
region.show()
region.save('./002.PNG')
执行效果:
原图 001.PNG
截取图 002.PNG