Reputation: 35
I have tried to make the following script running correctly:
def tftest():
from PIL import Image
picture = "ttamet3dim.png"
impict = Image.open(picture)
transf = impict.Image.transform((78,78), Image.QUAD, (78,41,178,27,183,91,81,91), Image.BICUBIC)
imt = Image.open(transf)
imt.show()
But I get the following error:
File "C:\Python34\tftest.py", line 5, in tftest
transf = impict.Image.transform(...)
File "C:\Python34\lib\site-packages\pillow-3.0.0-py3.4-win32.egg\PIL\Image.py", line 626, in __getattr__
AttributeError: Image
It's the first time that I use "transform"
. I wanted to have a look to the "transform"
script to see if I could find out what's wrong but my Pillow
is a .egg
so I didn't find how to access to the code. Do you know why I get this error and how to fix it?
Thank you, best regards
Upvotes: 2
Views: 959
Reputation: 2963
Try to change transf = impict.Image.transform
to transf = impict.transform
Upvotes: 1
Reputation:
You've assigned the Image
to the impict
variable here:
impict = Image.open(picture)
you should reference this variable, that's the opened image, with the transform:
impict.transform
instead of what you're currently doing (basically Image.open(picture).Image.transform
).
Upvotes: 0
Reputation: 55207
transform
is a method for Image
objects, and returns a new image:
from PIL import Image
def tftest():
picture = "ttamet3dim.png"
impict = Image.open(picture)
imt = impict.transform((78,78), Image.QUAD, (78,41,178,27,183,91,81,91), Image.BICUBIC)
imt.show()
Upvotes: 2