Views
No views yet
imghdr module for Python 3.13 and later.imghdr module was removed in Python 3.13 (PEP 594). This package provides the same API so existing code and dependencies (e.g. IO-Paint / IOPaint) can run on Python 3.13 without changes.pip install https://huggingface.co/ussoewwin/imghdr-1.0.0-py3-none-any/resolve/main/imghdr-1.0.0-py3-none-any.whlpip install imghdr-1.0.0-py3-none-any.whlpy3-none-any (pure Python, no platform-specific code), so it works on Windows, Linux, and macOS.1import imghdr
2
3# From file path
4fmt = imghdr.what("image.png") # -> "png"
5
6# From file-like object
7with open("photo.jpg", "rb") as f:
8 fmt = imghdr.what(f) # -> "jpeg"
9
10# From bytes
11fmt = imghdr.what(None, h=header_bytes)| Format | Return value |
|---|---|
| JPEG (JFIF/Exif) | "jpeg" |
| PNG | "png" |
| GIF 87a/89a | "gif" |
| TIFF | "tiff" |
| BMP | "bmp" |
| WebP | "webp" |
| PBM/PGM/PPM | "pbm" / "pgm" / "ppm" |
| SGI RGB | "rgb" |
| Sun Raster | "rast" |
| X Bitmap | "xbm" |
| OpenEXR | "exr" |
None if the format is not recognized.imghdr module. It is not affiliated with the Python Software Foundation.