Registry / serialization / pyexiftool

pyexiftool

JSON →
library0.5.6pypypi✓ verified 86d ago

PyExifTool provides a convenient Python interface to Phil Harvey's ExifTool, a powerful command-line application for reading, writing, and editing metadata in a wide variety of file formats. The current version is 0.5.6, and it maintains an active release cadence with new features and improvements.

pip install pyexiftool
INSTALL
IMPORT
SIG · PYEXIFTOOL
P
pyexiftool
serializationpythonv0.5.6
Install
1.5s avg
Import
—
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.5.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18MB
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 1.5s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ExifTool
✓ from exiftool import ExifTool
✗ from pyexiftool import ExifTool

This quickstart demonstrates how to instantiate ExifTool using a context manager and read metadata from an image file. It includes a fallback to create a dummy file for immediate execution, but real EXIF data requires a valid image. It also highlights the requirement for the `exiftool` command-line utility.

import os from pyexiftool import ExifTool # IMPORTANT: Ensure the 'exiftool' command-line utility is installed # and accessible on your system PATH. # For Debian/Ubuntu: sudo apt-get install libimage-exiftool-perl # For macOS: brew install exiftool # More info: https://exiftool.org/ # Create a dummy image file for demonstration if it doesn't exist image_file = "example.jpg" if not os.path.exists(image_file): with open(image_file, "w") as f: f.write("Simulated JPEG content\n") print(f"Created dummy file: {image_file}. Replace with a real image for meaningful EXIF data.") try: # Use ExifTool as a context manager to ensure proper process handling with ExifTool() as et: # Read all metadata from the image file metadata = et.get_metadata(image_file) print(f"\nMetadata for {image_file}:") for tag, value in metadata.items(): print(f" {tag}: {value}") # Example of writing metadata (uncomment and use a real image if needed) # For writing, ensure the image_file is a real image and you have write permissions. # new_tags = {"Exif.Image.Artist": "Python Bot", "Exif.Image.Copyright": "2023 Example Corp"} # et.set_tags(new_tags, [image_file]) # print(f"\nUpdated metadata for {image_file}") # updated_metadata = et.get_metadata(image_file) # print("Updated Artist:", updated_metadata.get("Exif.Image.Artist")) except Exception as e: print(f"An error occurred: {e}") print("Please ensure 'exiftool' is installed and your image file path is correct.") finally: # Clean up the dummy file if it was created if os.path.exists(image_file) and os.path.getsize(image_file) == len("Simulated JPEG content\n"): os.remove(image_file) print(f"Cleaned up dummy file: {image_file}")
Debug
Known issues
breakingPyExifTool v0.5.0 introduced a major refactor, breaking compatibility with previous 0.4.x versions. It requires Python 3.6+ and exiftool 12.15+.
fix
Review the updated documentation (sylikc.github.io/pyexiftool) and adapt your code to the new API (e.g., `get_metadata` instead of `get_tag`). Ensure your Python and exiftool versions meet the requirements.
affects: >=0.5.0
gotchaThe `exiftool` command-line utility must be separately installed and available in your system's PATH. PyExifTool is a wrapper and does not bundle it.
fix
Install `exiftool` via your operating system's package manager (e.g., `sudo apt install libimage-exiftool-perl` on Debian/Ubuntu, `brew install exiftool` on macOS) or download from `exiftool.org`.
affects: All versions
breakingStarting with v0.5.6, `ujson` is no longer automatically used for JSON parsing when available. You must explicitly configure it if you want to use a custom JSON library or `ujson`.
fix
If you wish to use `ujson` for performance, import `ujson` and then call `ExifTool.set_json_loads(ujson.loads)` after instantiation or globally.
affects: >=0.5.6
deprecatedPyExifTool ended Python 2 support with v0.4.13. All versions 0.5.0 and later require Python 3.6+.
fix
Upgrade your Python environment to Python 3.6 or newer if you plan to use PyExifTool v0.5.0 or later.
affects: >=0.5.0
breakingError class names were renamed in v0.5.3 to be more explicit (e.g., `ProcessStateError` became `ExifToolProcessStateError`).
fix
Update exception handling blocks to catch the new error class names.
affects: >=0.5.3
gotchaThe `ExifToolHelper` class (introduced in v0.5.2) now checks the `exiftool` subprocess exit status by default and raises `ExifToolExecuteError` on non-zero status. This can change behavior for scripts expecting silent failures.
fix
Review calls to `ExifToolHelper` methods and either handle `ExifToolExecuteError` or explicitly disable the `check_execute` parameter if old behavior is desired.
affects: >=0.5.2
Upgrade
Version history
0.5.6latest on PyPI · released Oct 22, 2023
Audit
Dependencies
exiftool (executable)requiredPyExifTool is a wrapper around the `exiftool` command-line utility, which must be installed separately on your system.
ujsonoptionalOptional, can be used for faster JSON parsing by manually configuring ExifTool.set_json_loads().
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
pyexiftool — pip install pyexiftool · libregistry