gpt4 book ai didi

image - PIL : module object has no attribute 'resize'

转载 作者:行者123 更新时间:2023-12-02 22:37:37 27 4
gpt4 key购买 nike

我正在尝试 PIL,它抛出了一个我觉得很奇怪的错误。

这是我所有的代码:

from PIL import Image, ImageOps

im = ("lenna.png")
imResize = Image.resize((200,200), Image.ANTIALIAS)

我正在通过 Windows Powershell 在命令行上执行此操作,前两个语句给出了我没问题。事实上,我什至尝试了 im.show() 并打开了图像,但是当我尝试 imResize 时,我收到以下错误:

AttributeError: 'module' object has no attribute 'resize'

然而,当我浏览 help(Image) 时,我可以在那里看到 resize 方法,而且我似乎一切正常。

请问我遗漏了什么吗?谢谢

最佳答案

[将答案作为答案:)]

改为调用变量的调整大小方法。所以 im.resize() 代替 Image.resize() 完成了工作。

关于image - PIL : module object has no attribute 'resize' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21496635/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com