Python(图像库): Resample string as argument

标签 python python-imaging-library

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/

相关文章:

python : Making a negative image of a RGB picture

python - 复制和合并不包括某些扩展名的目录

python - 使用 PIL 列出图像的所有 RGBA 值

python-3.x - Python PIL图像抓取崩溃

javascript - 如何将 Canvas 转换为图像以上传到 flask ?

text - PIL : using fromarray() with binary data and writing coloured text

python - 为什么 PIL 绘制多边形不接受 numpy 数组?

python - 自定义 python 回溯或调试输出

python - 在 OpenCV 中是否有任何用于检测左耳和右耳的 haar 级联?

选择表单时 Python Mechanize 错误