Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PIL: module object has no attribute 'resize'

I'm trying PIL and it is throwing an error which I find strange.

this is all the code I have:

from PIL import Image, ImageOps

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

I'm doing this on command line via Windows Powershell and the first two statements gave me no problem. Indeed I even tried im.show() and the image opened but when I tried the imResize, I get the following error:

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

Yet when I go through help(Image) I can see the resize method there and I seem to be doing everything alright.

Please is there anything I'm missing? Thanks

like image 630
user3237883 Avatar asked Jun 23 '26 20:06

user3237883


1 Answers

[Putting the answer as an answer :)]

Call the resize method on the variable instead. So im.resize() gets the job done instead of Image.resize().

like image 122
Hugo Avatar answered Jun 25 '26 19:06

Hugo