【发布时间】:2019-10-21 10:59:46
【问题描述】:
我想用 python 更改 Instagram 图像的纵横比。这是我更改纵横比的代码:
width,height=imageFile.size
aspectRatio = width/height
if(aspectRatio>=0.80 and aspectRatio<=1.90):
print("yeah")
else:
if(height>width):
futureHeight = width/.85
print(str(width)+" ,"+str(futureHeight))
print(width/futureHeight)
left = 0
int(futureHeight)
teetet = height-futureHeight/2
top = teetet / 4
right = width
bottom = height -150
im1 = imageFile.crop((left, top, right, bottom))
print(im1.size)
im1.show()
im1.save(image)
但它仍然显示 ValueError: 宽高比不兼容。
每当我尝试上传这张图片时
【问题讨论】:
-
检查 PIL 库中的“resize”和“thumbnail”:stackoverflow.com/questions/29367990/…
标签: python-3.x image-processing python-imaging-library instagram instagram-api