在Python中调整图像大小

时间:2015-07-01 07:38:01

标签: python image scipy python-imaging-library scikit-image

我有一个2500像素乘2500像素的jpg图像。

如何将它保存为4厘米高,3厘米宽,600 dpi?

from PIL import Image
img = Image.open('test.jpg')
new = img.resize((600,650), Image.NEAREST)  ###Not complete!
new.save('result.jpg','JPEG',dpi=(600,600))

1 个答案:

答案 0 :(得分:1)

您是否只想调整图像的宽度和高度,如下所示?

width = math.ceil((3.0 * 600.0) / 2.54)
height = math.ceil((4.0 * 600.0) / 2.54)

print "%u x %u" % (width, height)

,并提供:

709 x 945
相关问题