PhotoImage 实例没有属性“resize" [英] PhotoImage instance has no attribute 'resize'

查看:207
本文介绍了PhotoImage 实例没有属性“resize"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误 'PhotoImage instance has no attribute 'resize'' 尽管多个在线资源表明这是使用 PIL 调整图像大小的方法.有什么想法吗?

Im geting the error 'PhotoImage instance has no attribute 'resize'' despite multiple online sources stating that this is the way to do resize an image using PIL. Any Ideas?

相关代码:

Deathwing = ImageTk.PhotoImage(Image.open('Deathwing.PNG'))

Deathwing2=Deathwing.resize((100,50),Image.ANTIALIAS)

picture1=Label(pictures_frame,image=Deathwing2)

picture1.grid(column=1,row=1)

和 PIL 被导入为:

and PIL is impoted as:

from PIL import Image,ImageTk

推荐答案

对于任何有同样问题的人,我通过以下方式解决了:

For anyone who has the same problem I fixed it by doing:

 deathwing=Image.open('Deathwing.PNG')
 image2=deathwing.resize((100,50),Image.ANTIALIAS)
 Deathwing2=ImageTk.PhotoImage(image2)

这篇关于PhotoImage 实例没有属性“resize"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆