PhotoImage for images in PGM, PPM, GIF and PNG formats. The latter is supported starting with Tk 8.6.
Information about my environment,
- WIN10
- Python 3.6.0
- tkinter.TkVersion 8.6
- tkinter.Tcl().eval('info patchlevel') 8.6.6
I got some PNG files failed in following script
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()
Different PNG files can be downloaded from
File header for both files are the same 89 50 4E 47 0D 0A 1A 0A
for PNG file. Both files can be shown without any problem under lot of softwares, lik windows File manager, ACDSEE, Paint, ...
Failure information for different PNG files
# 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, name,) + options)
_tkinter.TclError: encountered an unsupported criticial chunk type "orNT"
# duck.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, name,) + options)
_tkinter.TclError: encountered an unsupported criticial chunk type "eXIf"
Library Pillow (PIL)
may help to work, but not the question here.
My questions are
- Do python 3.6.x with tkinter 8.6 support all PNG files ?
- If not, what format or version of PNG file get support ?