{"id":5213,"library":"exifread","title":"ExifRead Library","description":"ExifRead is a Python library designed to extract Exif metadata from digital camera image files, including JPEG, TIFF, and HEIC/HEIF formats. It provides a straightforward API to access various EXIF tags, maker notes, and thumbnails. The library is actively maintained, with frequent minor releases (typically monthly or bi-monthly) to add support for new camera models, file formats, and address bug fixes. The current version is 3.5.1.","status":"active","version":"3.5.1","language":"en","source_language":"en","source_url":"https://github.com/ianare/exif-py","tags":["exif","metadata","image","jpeg","tiff","heic"],"install":[{"cmd":"pip install exifread","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The library is typically imported as 'exifread' and its functions are called directly from the module.","symbol":"exifread","correct":"import exifread"}],"quickstart":{"code":"import exifread\nimport os\n\n# Create a dummy image file for demonstration\n# In a real scenario, you'd open an existing image.\n# For a runnable example, we'll create a placeholder that can be opened.\n# This will likely fail to extract *real* EXIF but demonstrates the API.\nwith open('dummy_image.jpg', 'wb') as f:\n    f.write(b'\\xff\\xd8\\xff\\xe0\\x00\\x10JFIF\\x00\\x01\\x01\\x00\\x00\\x01\\x00\\x01\\x00\\x00\\xff\\xdb\\x00C\\x00\\x08\\x06\\x06\\x07\\x06\\x05\\x08\\x07\\x07\\x07\\t\\t\\x08\\n\\x0c\\x14\\r\\x0c\\x0b\\x0b\\x0c\\x19\\x12\\x13\\x0f\\x14\\x1d\\x1a\\x1f\\x1e\\x1d\\x1a\\x1c\\x1c\\x20\"!\\22\\\"\\22\\x15\\x15\\x20\\x2f\\x36\\x28\\x30\\x3d\\x30\\x28\\x2c\\x32\\x34\\x34\\x34\\x1f\\x27\\x39\\x3d\\x38\\x32\\x3c\\x2e\\x33\\x34\\x30\\xff\\xc0\\x00\\x11\\x08\\x00\\x01\\x00\\x01\\x03\\x01\\x22\\x00\\x02\\x11\\x01\\x03\\x11\\x01\\xff\\xc4\\x00\\x1f\\x00\\x00\\x01\\x05\\x01\\x01\\x01\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\xff\\xc4\\x00\\xb5\\x10\\x00\\x02\\x01\\x03\\x03\\x02\\x04\\x03\\x05\\x05\\x04\\x04\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x11\\x01\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\x21\\x22\\x23\\x24\\x25\\x26\\x27\\x28\\x29\\x2a\\x31\\x32\\x33\\x34\\x35\\x36\\x37\\x38\\x39\\x3a\\x41\\x42\\x43\\x44\\x45\\x46\\x47\\x48\\x49\\x4a\\x51\\x52\\x53\\x54\\x55\\x56\\x57\\x58\\x59\\x5a\\x61\\x62\\x63\\x64\\x65\\x66\\x67\\x68\\x69\\x6a\\x71\\x72\\x73\\x74\\x75\\x76\\x77\\x78\\x79\\x7a\\x81\\x82\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8a\\x91\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9a\\xa1\\xa2\\xa3\\xa4\\xa5\\xa6\\xa7\\xa8\\xa9\\xaahundred_times\\xff\\xda\\x00\\x0c\\x03\\x01\\x00\\x02\\x11\\x03\\x11\\x00\\x3f\\x00\\xd2\\xcf\\x20\\xff\\xd9')\n\nimage_path = 'dummy_image.jpg'\n\ntry:\n    with open(image_path, 'rb') as f:\n        tags = exifread.process_file(f, strict=False)\n\n    if tags:\n        print(f\"EXIF data for {image_path}:\")\n        for tag_name, tag_value in tags.items():\n            # Filter for some common tags\n            if tag_name not in ('JPEGThumbnail', 'TIFFThumbnail', 'Filename', 'EXIF MakerNote'):\n                print(f\"  {tag_name}: {tag_value}\")\n        \n        # Access a specific tag, handling potential KeyError\n        if 'EXIF DateTimeOriginal' in tags:\n            print(f\"\\nOriginal Date/Time: {tags['EXIF DateTimeOriginal'].printable}\")\n        else:\n            print(\"\\n'EXIF DateTimeOriginal' tag not found.\")\n    else:\n        print(f\"No EXIF data found in {image_path}.\")\nexcept FileNotFoundError:\n    print(f\"Error: File not found at {image_path}\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\nfinally:\n    # Clean up the dummy file\n    if os.path.exists(image_path):\n        os.remove(image_path)","lang":"python","description":"This quickstart demonstrates how to open an image file, process it with `exifread.process_file()`, and iterate through the extracted EXIF tags. It includes an example of accessing a specific tag and recommends using `strict=False` for broader compatibility with potentially malformed maker notes."},"warnings":[{"fix":"Upgrade to Python 3.7 or newer. If forced to use older Python, pin `exifread` to `<3.0` for Python 2.x or `<3.1` for Python 3.5/3.6.","message":"Python 2.x compatibility was removed in version 3.0.0. Python 3.5 and 3.6 support was dropped in version 3.1.0. Users on older Python versions must use an older `exifread` version.","severity":"breaking","affected_versions":">=3.0.0 (Python 2.x), >=3.1.0 (Python 3.5/3.6)"},{"fix":"Always check for the tag's existence using `if 'Tag Name' in tags:` or use the `.get()` method (e.g., `tags.get('Tag Name')`) to safely retrieve values and handle missing tags.","message":"Accessing EXIF tags by dictionary key (e.g., `tags['Tag Name']`) will raise a `KeyError` if the tag does not exist in the image's metadata. Not all images contain all possible EXIF tags.","severity":"gotcha","affected_versions":"All versions"},{"fix":"After retrieving a tag object, access its `.printable` attribute for display: `tag_value = tags['Tag Name'].printable`. For specific numerical components, refer to the tag object's other attributes.","message":"The values returned from `exifread.process_file` are `IFD_Tag` objects, not raw strings or numbers. To get a human-readable string representation, you typically need to access the `.printable` attribute. Other attributes like `.values`, `.num`, `.den` provide raw data.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Pass `strict=False` to `exifread.process_file()` to attempt to parse data more leniently, avoiding exceptions for potentially unparseable or custom maker notes: `tags = exifread.process_file(f, strict=False)`.","message":"By default (`strict=True`), `exifread.process_file` can raise exceptions for malformed or non-standard maker notes, especially with some camera models. Version 3.5.1 fixed an issue where `strict=False` wasn't always honored.","severity":"gotcha","affected_versions":"<3.5.1, and all versions if `strict=True` is used or implicit."}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}