在Python中调整图像大小

问题描述:

我有一个尺寸的图像(288,352)。我想调整它到(160,240)。 我尝试下面的代码:在Python中调整图像大小

im = imread('abc.png') 
img = im.resize((160, 240), Image.ANTIALIAS) 

但它给出了一个错误TypeError: an integer is required 请告诉我这样做的最佳方式。

matplotlib.pyplot.imread(或scipy.ndimage.imread)返回一个NumPy数组,而不是一个PIL图像。

而是尝试:

In [25]: import Image 
In [26]: img = Image.open(FILENAME) 
In [32]: img.size 
Out[32]: (250, 250) 

In [27]: img = img.resize((160, 240), Image.ANTIALIAS) 

In [28]: img.size 
Out[28]: (160, 240) 
+0

谢谢,这是工作:) – Khushboo 2013-04-29 12:20:28