搭配 instagrapi 上传至instagram
def crop_image()::
im = Image.open('example.jpg')
width, height = im.size
if width > height:
left = int((width - height) / 2)
top = 0
right = width - left
bottom = height
crop = im.crop((left, top, right, bottom))
if height > width:
left = 0
top = int((height - width) / 2)
right = width
bottom = height-top
crop = im.crop((left, top, right, bottom))
# 正方形
else:
return
crop.save('example.jpg')
Comments NOTHING