Python 图像缩放
image.缩略图((128128),image.ANTIALIAS) PIL将新图像的高度设置为给定的大小(此处为128),并计算宽度以保持纵横比Python 图像缩放,python,imagemagick,python-imaging-library,Python,Imagemagick,Python Imaging Library,image.缩略图((128128),image.ANTIALIAS) PIL将新图像的高度设置为给定的大小(此处为128),并计算宽度以保持纵横比 有没有办法将宽度设置为128并让其计算高度以保持纵横比?根据文档缩略图方法: Modifies the image to contain a thumbnail version of itself, no larger than the given size. 尝试将宽度设置为128,并使用一个大数字(例如10000)作为高度。如果所有其他操作都
有没有办法将宽度设置为128并让其计算高度以保持纵横比?根据文档缩略图方法:
Modifies the image to contain a thumbnail version of itself, no larger than the given size.
尝试将宽度设置为128,并使用一个大数字(例如10000)作为高度。如果所有其他操作都失败,您可以始终直接使用python作为计算器:
width_ratio = image.size[0]/128.0
new_height = image.size[1]/width_ratio