AttributeError:“图像”对象没有属性“缩略图”

时间:2019-08-12 16:42:06

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

我再次遇到此错误,我又不知道我在哪里做错

from skimage import io
from PIL import Image
size= 363, 310
img = io.imread(url)
image = img.thumbnail(size, Image.ANTIALIAS)

1 个答案:

答案 0 :(得分:0)

我尝试了您的代码,但收到错误:AttributeError: 'Array' object has no attribute 'thumbnail'。 我通过执行以下操作将io的imread方法返回的数组转换为Image对象来纠正代码:

from skimage import io
from PIL import Image
size= 363, 310
img_array = io.imread(url) # this actually returns an image array
img = Image.fromarray(img_array) # turn the array into Image object
image = img.thumbnail(size, Image.ANTIALIAS)

我不确定您是否可能在标题为'Image' object has no attribute 'thumbnail'的地方写错了标题,但这是我最好的建议。如果实际上您没有写错该错误并且仍然存在,那么也许您应该重新安装PIL版本? 希望能帮助到你! :)