Python初学者问题。下面的代码应该可以解释我的问题:
import Image
resolution = (200,500)
scaler = "Image.ANTIALIAS"
im = Image.open("/home/user/Photos/DSC00320.JPG")
im.resize(resolution , scaler)
结果:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/dist-packages/PIL/Image.py", line 1255, in resize
raise ValueError("unknown resampling filter")
ValueError: unknown resampling filter
这个有效:
im.resize(resolution , Image.ANTIALIAS)
最佳答案
好吧,那么 Image.ANTIALIAS 不是一个字符串,所以不要把它当作一个:
scaler = Image.ANTIALIAS
关于Python(图像库): Resample string as argument,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1367029/