{"id":10096,"library":"pyexiftool","title":"PyExifTool","description":"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.","status":"active","version":"0.5.6","language":"en","source_language":"en","source_url":"https://github.com/sylikc/pyexiftool","tags":["exif","metadata","image","media","photography","wrapper"],"install":[{"cmd":"pip install pyexiftool","lang":"bash","label":"Install PyExifTool"}],"dependencies":[{"reason":"PyExifTool is a wrapper around the `exiftool` command-line utility, which must be installed separately on your system.","package":"exiftool (executable)","optional":false},{"reason":"Optional, can be used for faster JSON parsing by manually configuring ExifTool.set_json_loads().","package":"ujson","optional":true}],"imports":[{"symbol":"ExifTool","correct":"from pyexiftool import ExifTool"},{"note":"ExifToolHelper provides a higher-level API, especially useful for common metadata operations.","symbol":"ExifToolHelper","correct":"from pyexiftool import ExifToolHelper"}],"quickstart":{"code":"import os\nfrom pyexiftool import ExifTool\n\n# IMPORTANT: Ensure the 'exiftool' command-line utility is installed\n# and accessible on your system PATH.\n# For Debian/Ubuntu: sudo apt-get install libimage-exiftool-perl\n# For macOS: brew install exiftool\n# More info: https://exiftool.org/ \n\n# Create a dummy image file for demonstration if it doesn't exist\nimage_file = \"example.jpg\"\nif not os.path.exists(image_file):\n    with open(image_file, \"w\") as f:\n        f.write(\"Simulated JPEG content\\n\")\n    print(f\"Created dummy file: {image_file}. Replace with a real image for meaningful EXIF data.\")\n\ntry:\n    # Use ExifTool as a context manager to ensure proper process handling\n    with ExifTool() as et:\n        # Read all metadata from the image file\n        metadata = et.get_metadata(image_file)\n        print(f\"\\nMetadata for {image_file}:\")\n        for tag, value in metadata.items():\n            print(f\"  {tag}: {value}\")\n\n        # Example of writing metadata (uncomment and use a real image if needed)\n        # For writing, ensure the image_file is a real image and you have write permissions.\n        # new_tags = {\"Exif.Image.Artist\": \"Python Bot\", \"Exif.Image.Copyright\": \"2023 Example Corp\"}\n        # et.set_tags(new_tags, [image_file])\n        # print(f\"\\nUpdated metadata for {image_file}\")\n        # updated_metadata = et.get_metadata(image_file)\n        # print(\"Updated Artist:\", updated_metadata.get(\"Exif.Image.Artist\"))\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure 'exiftool' is installed and your image file path is correct.\")\nfinally:\n    # Clean up the dummy file if it was created\n    if os.path.exists(image_file) and os.path.getsize(image_file) == len(\"Simulated JPEG content\\n\"):\n        os.remove(image_file)\n        print(f\"Cleaned up dummy file: {image_file}\")","lang":"python","description":"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."},"warnings":[{"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.","message":"PyExifTool v0.5.0 introduced a major refactor, breaking compatibility with previous 0.4.x versions. It requires Python 3.6+ and exiftool 12.15+.","severity":"breaking","affected_versions":">=0.5.0"},{"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`.","message":"The `exiftool` command-line utility must be separately installed and available in your system's PATH. PyExifTool is a wrapper and does not bundle it.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If you wish to use `ujson` for performance, import `ujson` and then call `ExifTool.set_json_loads(ujson.loads)` after instantiation or globally.","message":"Starting 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`.","severity":"breaking","affected_versions":">=0.5.6"},{"fix":"Upgrade your Python environment to Python 3.6 or newer if you plan to use PyExifTool v0.5.0 or later.","message":"PyExifTool ended Python 2 support with v0.4.13. All versions 0.5.0 and later require Python 3.6+.","severity":"deprecated","affected_versions":">=0.5.0"},{"fix":"Update exception handling blocks to catch the new error class names.","message":"Error class names were renamed in v0.5.3 to be more explicit (e.g., `ProcessStateError` became `ExifToolProcessStateError`).","severity":"breaking","affected_versions":">=0.5.3"},{"fix":"Review calls to `ExifToolHelper` methods and either handle `ExifToolExecuteError` or explicitly disable the `check_execute` parameter if old behavior is desired.","message":"The `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.","severity":"gotcha","affected_versions":">=0.5.2"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install `exiftool` using your operating system's package manager (e.g., `sudo apt install libimage-exiftool-perl` on Debian/Ubuntu, `brew install exiftool` on macOS) or download it from `exiftool.org` and ensure it's in your PATH.","cause":"The `exiftool` command-line utility is not installed on your system or is not located in a directory listed in your system's PATH environment variable.","error":"FileNotFoundError: [Errno 2] No such file or directory: 'exiftool'"},{"fix":"Update your code to use the new API methods such as `et.get_metadata(filename)` to read tags and `et.set_tags(tags_dict, [filename])` to write tags. Refer to the current documentation.","cause":"Your code is likely using an older API pattern (from v0.4.x) that is incompatible with PyExifTool v0.5.x and later, which underwent a major refactor.","error":"AttributeError: 'ExifTool' object has no attribute 'get_tag' (or 'set_tag')"},{"fix":"Always use `ExifTool` within a `with` statement (`with ExifTool() as et:`), which handles starting and terminating the process automatically, or manually call `et.start()` before use and `et.terminate()` afterwards.","cause":"An `ExifTool` instance was used without explicitly starting the underlying `exiftool` process or without using a context manager (`with ExifTool() as et:`).","error":"pyexiftool.exceptions.ExifToolProcessStateError: Process is not running. Call start() or use a context manager."},{"fix":"If you need to customize JSON parsing (e.g., to use `ujson`), use the new `ExifTool.set_json_loads(custom_loads_function)` method introduced in v0.5.6. The auto-detection of `ujson` was also removed, requiring explicit configuration.","cause":"Prior to v0.5.6, `pyexiftool` allowed setting a custom JSON library via `set_json_library()`. This method was removed, and the mechanism changed in v0.5.6.","error":"AttributeError: 'ExifTool' object has no attribute 'set_json_library'"}]}