imghdr 1.0.0 (Python 3.13+)

Backport of the Python standard library imghdr module for Python 3.13 and later.

The 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.

Installation

From this Hugging Face repo

pip install https://huggingface.co/ussoewwin/imghdr-1.0.0-py3-none-any/resolve/main/imghdr-1.0.0-py3-none-any.whl

Or clone the repo and install the wheel:

pip install imghdr-1.0.0-py3-none-any.whl

Requirements

  • Python >= 3.13

The wheel is py3-none-any (pure Python, no platform-specific code), so it works on Windows, Linux, and macOS.

Usage

Same as the former standard library:

import imghdr

# From file path
fmt = imghdr.what("image.png")   # -> "png"

# From file-like object
with open("photo.jpg", "rb") as f:
    fmt = imghdr.what(f)         # -> "jpeg"

# From bytes
fmt = imghdr.what(None, h=header_bytes)

Supported formats

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"

Returns None if the format is not recognized.

License

Apache-2.0

Note

This package reimplements the behavior of the removed stdlib imghdr module. It is not affiliated with the Python Software Foundation.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support