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
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()
尝试将transf = impict.Image.transform
transf = impict.transform
更改transf = impict.Image.transform
transf = impict.transform
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
).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.