Tkinter: Couldn't recognize data in image file

2020-05-01 09:46发布

I have the following problem. I generate .GIF files using an external application. To me the GIFs look fine, I can open them without problems. However, using

        photo = PhotoImage(file=screenshot_file)
        self.previewImageLabel.config(image=photo)
        self.previewImageLabel.image = photo

to add an image to a Tkinter Label, is giving me the following error:

TclError: couldn't recognize data in image file "C:\Users\D8W\Python\hoang\combi ne_model_neu\test_bauteile\SQTR-VO\prev_F45_SQTR.GIF"

The thing is, when I upload one of the GIFs to some online Converter and convert them to "GIF", they get displayed perfectly fine. So my external application, which generates the GIFs, is putting something in there that Tkinter doesn't like.

How can I modify the GIFs to work? What are alternatives solving this problem? I may not use modules that are not included in Python(like PIL).

Do you have any ideas? Thanks in advance

1条回答
Luminary・发光体
2楼-- · 2020-05-01 09:55

I solved it, the problem was within my external application. I specified the file as .GIF but I have set the type to PNG.

Thanks anyway

查看更多
登录 后发表回答