The `standard-imghdr` library is a redistribution of the `imghdr` module, which was formerly part of the Python standard library. It provides functionality to determine the type of an image file based on its header. Maintained by the `python-deadlib` project, this library serves as a compatibility layer for projects that relied on `imghdr` after its deprecation in Python 3.11 and subsequent removal in Python 3.13. The current version is 3.13.0 and it follows an infrequent release cadence focused on maintaining compatibility.
pip install standard-imghdrVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `imghdr.what()` to identify image types from both a filename and a byte stream. It creates temporary dummy JPEG and PNG files, identifies their types, and then cleans up the files.
For existing code, install `standard-imghdr` (`pip install standard-imghdr`). For new code, consider using more robust and actively maintained alternatives like `Pillow`, `filetype`, `puremagic`, or `python-magic`.
Avoid using `standard-imghdr` for new projects or new image handling logic. Migrate to actively maintained third-party libraries (e.g., `Pillow`, `filetype`) that offer more comprehensive and current image detection capabilities.
Always use virtual environments (`python -m venv .venv` followed by `source .venv/bin/activate`) when installing Python packages. If a system-wide installation is absolutely necessary and issues arise, a workaround like `pip install standard-imghdr --break-system-packages` might be needed on some systems (e.g., Arch Linux), but this is generally discouraged as it can break system Python packages.
Install the `standard-imghdr` package using pip, which provides the original `imghdr` module: `pip install standard-imghdr`
After installing `standard-imghdr` with `pip install standard-imghdr`, continue to import the module using its original name: `import imghdr` or `from imghdr import what`.
Reinstall `standard-imghdr` to ensure a clean and correct installation: `pip uninstall standard-imghdr && pip install standard-imghdr`. Verify your Python environment's module paths if the issue persists.
No dependency data recorded yet.