[英]PIL resizing image
image.thumbnail((128,128),Image.ANTIALIAS)
PIL将新图像的高度设置为给定的大小(此处为128),并计算宽度以保持宽高比。
有没有一种方法可以将width设置为128并让其计算高度以保持纵横比?
如果所有其他方法都失败了,那么您始终可以直接将python直接用作计算器:
width_ratio = image.size[0]/128.0
new_height = image.size[1]/width_ratio
根据文档缩略图方法:
Modifies the image to contain a thumbnail version of itself, no larger than the given size.
尝试将宽度设置为128,并使用一个较大的数字(例如10000)作为高度。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.