1 def what(file=None, h
=None):
2 """Detect format of image (Currently supports jpeg, png, webp, gif only)
3 Ref: https://github.com/python/cpython/blob/3.11/Lib/imghdr.py
4 Ref: https://www.w3.org/Graphics/JPEG/itu-t81.pdf
7 with
open(file, 'rb') as f
:
10 if h
.startswith(b
'RIFF') and h
.startswith(b
'WEBP', 8):
13 if h
.startswith(b
'\x89PNG'):
16 if h
.startswith(b
'\xFF\xD8\xFF'):
19 if h
.startswith(b
'GIF'):