问题描述
PhotoImage 用于 pgm、PPM、GIF 和 PNG 格式的图像。从 Tk 8.6 开始支持后者。
有关我的环境的信息,
- WIN10
- Python 3.6.0
- tkinter.TkVersion 8.6
- tkinter.Tcl().eval('info patchlevel') 8.6.6
我的一些 PNG 文件在以下脚本中失败
from tkinter import *
root = Tk()
bg = PhotoImage(file='d:/Fandom.png') # Failed here
bg_label = Label(root,image=bg)
bg_label.place(x=0,y=0,relwidth=1,relheight=1)
root.mainloop()
可以从以下位置下载不同的 PNG 文件
两个文件的文件头对于 PNG 文件是相同的 89 50 4E 47 0D 0A 1A 0A
。这两个文件都可以在很多软件下正常显示,比如 windows 文件管理器、ACDSEE、Paint ......
不同PNG文件的失败信息
# Fandom.png
Traceback (most recent call last):
File "<module1>",line 5,in <module>
File "C:\Software\Python\lib\tkinter\__init__.py",line 3539,in __init__
Image.__init__(self,'photo',name,cnf,master,**kw)
File "C:\Software\Python\lib\tkinter\__init__.py",line 3495,in __init__
self.tk.call(('image','create',imgtype,) + options)
_tkinter.TclError: encountered an unsupported criticial chunk type "orNT"
# duck.png
Traceback (most recent call last):
File "<module1>",) + options)
_tkinter.TclError: encountered an unsupported criticial chunk type "eXIf"
图书馆 Pillow (PIL)
可能有助于工作,但不是这里的问题。
我的问题是
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)