How to Check if a File is a Valid Image with Python
Python has many modules in its standard library. One that is often overlooked is imghdr which lets you identify what image type that is contained in a file, byte stream or path-like object.
The imghdr can recognize the following image types:


