[英]Using Python 3.4 and Pillow and the method transform: AttributeError: Image
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"
. 这是我第一次使用
"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. 我想看一下
"transform"
脚本,看看是否可以找出问题所在,但是我的Pillow
是.egg
因此我找不到如何访问代码。 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: transform
是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: 您已在此处将
Image
分配给impict
变量:
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
). 而不是您当前正在做什么(基本上是
Image.open(picture).Image.transform
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.