Home > database >  Is .png the only format acceptable in python's tkinter module?
Is .png the only format acceptable in python's tkinter module?

Time:09-09

I tried inserting a picture with format .jpg as a PhotoImage

But everytime i try running the program, it gives the following error:

couldn't recognize data in image file

But this never happens with an .png picture, which makes me wonder if .png is the only format acceptable in tkinter?

CodePudding user response:

The docstring for PhotoImage says:

class PhotoImage(Image):
    """Widget which can display images in PGM, PPM, GIF, PNG format."""

So no, PNG is not the only acceptable format. PGM, PPM, GIF, and PNG are. JPEG is not.

  • Related