Getting a set of supported PIL file extensions

I’m working on a program to organize image files and I’m using PIL to open them. I would like the program to ignore non-image files without having to try opening them.
Does PIL have a function that returns a list or a set of all its supported image file types?


Is this a GUI app? command line?
Are you simply trying to filter by file type (extension)?
Are you tying to to find out what file types PIL supports?

If you could flesh this out some, it may help with coming up with a constructive response for you.

1 Like
1 Like

It’s a GUI (tkinter) app to manually categorize images from a folder into others.
The idea is that, for each image, you see it portrayed in the window and you press a button to move or copy it in a corresponding destination, quickly moving on to the next image.
Of course, I want to skip non-image file extensions, so for each file I need to check its type against a list of valid ones.

The PIL library supports a variety of extensions, but I don’t want to manually build a list of them (mostly because they might add new ones), so my objective would be to extract the list of valid formats directly from the library itself

Just my luck, SO is down for maintenance

EDIT: it’s up again. The answer from OP worked, thank you