How to get the format of image with PIL?
Solution 1:
Try:
img = Image.open(filename)
print(img.format) # 'JPEG'
More info
-
https://pillow.readthedocs.io/en/latest/reference/Image.html#PIL.Image.Image.format
-
https://pillow.readthedocs.io/en/latest/handbook/image-file-formats.html