ExifRead


NameExifRead JSON
Version 3.3.2 PyPI version JSON
download
home_pageNone
SummaryLibrary to extract Exif information from digital camera image files.
upload_time2025-07-17 21:24:05
maintainerNone
docs_urlNone
authorIanaré Sévi
requires_python>=3.7
license Copyright (c) 2002-2007 Gene Cash Copyright (c) 2007-2025 Ianaré Sévi and contributors Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the authors nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords exif image metadata photo
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            *******
EXIF.py
*******

.. image:: https://img.shields.io/github/license/ianare/exif-py
    :target: https://opensource.org/license/bsd-3-clause
    :alt: BSD-3-clause
.. image:: https://img.shields.io/pypi/v/ExifRead
    :target: https://pypi.org/project/ExifRead
    :alt: PyPi
.. image:: https://img.shields.io/pypi/dm/ExifRead
    :target: https://opensource.org/license/bsd-3-clause
    :alt: BSD-3-clause
.. image:: http://www.mypy-lang.org/static/mypy_badge.svg
    :target: http://mypy-lang.org/
    :alt: Checked with mypy
.. image:: https://img.shields.io/github/actions/workflow/status/ianare/exif-py/test.yml
    :target: https://github.com/ianare/exif-py
    :alt: Tests

|

Easy to use Python module to extract Exif metadata from digital image files.

Pure Python, lightweight, no dependencies.

Supported formats: TIFF, JPEG, PNG, Webp, HEIC


Compatibility
*************

EXIF.py is tested and officially supported on Python 3.7 to 3.13


Installation
************

Stable Version
==============
The recommended process is to install the `PyPI package <https://pypi.python.org/pypi/ExifRead>`_,
as it allows easily staying up to date::

    $ pip install exifread

See the `pip documentation <https://pip.pypa.io/en/latest/user_guide.html>`_ for more info.

EXIF.py is mature software and strives for stability.

Development Version
===================

After cloning the repo, use the provided Makefile::

  make venv install-all

Which will create a virtual environment and install development dependencies.

Usage
*****

Command line
============

Some examples::

    EXIF.py image1.jpg
    EXIF.py -dc image1.jpg image2.tiff
    find ~/Pictures -name "*.jpg" -o -name "*.tiff" | xargs EXIF.py

Show command line options::

    EXIF.py -h

Python Script
=============

.. code-block:: python

    import exifread

    # Open image file for reading (must be in binary mode)
    with open(file_path, "rb") as file_handle:

        # Return Exif tags
        tags = exifread.process_file(file_handle)

*Note:* To use this library in your project as a Git submodule, you should::

    from <submodule_folder> import exifread

Returned tags will be a dictionary mapping names of Exif tags to their
values in the file named by ``file_path``.
You can process the tags as you wish. In particular, you can iterate through all the tags with:

.. code-block:: python

    for tag, value in tags.items():
        if tag not in ('JPEGThumbnail', 'TIFFThumbnail', 'Filename', 'EXIF MakerNote'):
            print(f"Key: {tag}, value {value}")

An ``if`` statement is used to avoid printing out a few of the tags that tend to be long or boring.

The tags dictionary will include keys for all of the usual Exif tags, and will also include keys for
Makernotes used by some cameras, for which we have a good specification.

Note that the dictionary keys are the IFD name followed by the tag name. For example::

    'EXIF DateTimeOriginal', 'Image Orientation', 'MakerNote FocusMode'


Tag Descriptions
****************

Tags are divided into these main categories:

- ``Image``: information related to the main image (IFD0 of the Exif data).
- ``Thumbnail``: information related to the thumbnail image, if present (IFD1 of the Exif data).
- ``EXIF``: Exif information (sub-IFD).
- ``GPS``: GPS information (sub-IFD).
- ``Interoperability``: Interoperability information (sub-IFD).
- ``MakerNote``: Manufacturer specific information. There are no official published references for these tags.


Processing Options
******************

These options can be used both in command line mode and within a script.

Faster Processing
=================

Don't process makernote tags, don't extract the thumbnail image (if any).

Pass the ``-q`` or ``--quick`` command line arguments, or as:

.. code-block:: python

    tags = exifread.process_file(
        file_handle, details=False, extract_thumbnail=False
    )

To process makernotes only, without extracting the thumbnail image (if any):

.. code-block:: python

    tags = exifread.process_file(
        file_handle, details=True, extract_thumbnail=False
    )

To extract the thumbnail image (if any), without processing makernotes:

.. code-block:: python

    tags = exifread.process_file(
        file_handle, details=False, extract_thumbnail=True
    )

Stop at a Given Tag
===================

To stop processing the file after a specified tag is retrieved.

Pass the ``-t TAG`` or ``--stop-tag TAG`` argument, or as:

.. code-block:: python

    tags = exifread.process_file(file_handle, stop_tag='TAG')

where ``TAG`` is a valid tag name without the IFD, ex ``'DateTimeOriginal'``.

*The two above options are useful to speed up processing of large numbers of files.*

Strict Processing
=================

Return an error on invalid tags instead of silently ignoring.

Pass the ``-s`` or ``--strict`` argument, or as:

.. code-block:: python

    tags = exifread.process_file(file_handle, strict=True)

Built-in Types
==============

For easier serialization and programmatic use, this option returns a dictionary with values in built-in Python types
(int, float, str, bytes, list, None) instead of `IfdTag` objects.

Pass the ``-b`` or ``--builtin`` argument, or as:

.. code-block:: python

    tags = exifread.process_file(file_handle, builtin_types=True)

For direct JSON serialization, combine this option with ``details=False`` to avoid bytes in the output:

.. code-block:: python

    json.dumps(exifread.process_file(file_handle, details=False, builtin_types=True))

Usage Example
=============

This example shows how to use the library to correct the orientation of an image
(using Pillow for the transformation) before e.g. displaying it.

.. code-block:: python

    import exifread
    from PIL import Image
    import logging

    def _read_img_and_correct_exif_orientation(path):
        im = Image.open(path)
        tags = {}
        with open(path, "rb") as file_handle:
            tags = exifread.process_file(file_handle, details=False)

        if "Image Orientation" in tags:
            orientation = tags["Image Orientation"]
            logging.basicConfig(level=logging.DEBUG)
            logging.debug("Orientation: %s (%s)", orientation, orientation.values)
            val = orientation.values
            if 2 in val:
                val += [4, 3]
            if 5 in val:
                val += [4, 6]
            if 7 in val:
                val += [4, 8]
            if 3 in val:
                logging.debug("Rotating by 180 degrees.")
                im = im.transpose(Image.ROTATE_180)
            if 4 in val:
                logging.debug("Mirroring horizontally.")
                im = im.transpose(Image.FLIP_TOP_BOTTOM)
            if 6 in val:
                logging.debug("Rotating by 270 degrees.")
                im = im.transpose(Image.ROTATE_270)
            if 8 in val:
                logging.debug("Rotating by 90 degrees.")
                im = im.transpose(Image.ROTATE_90)
        return im


License
*******

Copyright © 2002-2007 Gene Cash

Copyright © 2007-2025 Ianaré Sévi and contributors

A **huge** thanks to all the contributors over the years!

Originally written by Gene Cash & Thierry Bousch.

Available as open source under the terms of the **BSD-3-Clause license**.

See the LICENSE file for details.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ExifRead",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "exif, image, metadata, photo",
    "author": "Ianar\u00e9 S\u00e9vi",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/06/e4/a1464fda6c9daac90d7d64ed4d5fc6e908896e0886326de23c923ddfbfce/exifread-3.3.2.tar.gz",
    "platform": null,
    "description": "*******\nEXIF.py\n*******\n\n.. image:: https://img.shields.io/github/license/ianare/exif-py\n    :target: https://opensource.org/license/bsd-3-clause\n    :alt: BSD-3-clause\n.. image:: https://img.shields.io/pypi/v/ExifRead\n    :target: https://pypi.org/project/ExifRead\n    :alt: PyPi\n.. image:: https://img.shields.io/pypi/dm/ExifRead\n    :target: https://opensource.org/license/bsd-3-clause\n    :alt: BSD-3-clause\n.. image:: http://www.mypy-lang.org/static/mypy_badge.svg\n    :target: http://mypy-lang.org/\n    :alt: Checked with mypy\n.. image:: https://img.shields.io/github/actions/workflow/status/ianare/exif-py/test.yml\n    :target: https://github.com/ianare/exif-py\n    :alt: Tests\n\n|\n\nEasy to use Python module to extract Exif metadata from digital image files.\n\nPure Python, lightweight, no dependencies.\n\nSupported formats: TIFF, JPEG, PNG, Webp, HEIC\n\n\nCompatibility\n*************\n\nEXIF.py is tested and officially supported on Python 3.7 to 3.13\n\n\nInstallation\n************\n\nStable Version\n==============\nThe recommended process is to install the `PyPI package <https://pypi.python.org/pypi/ExifRead>`_,\nas it allows easily staying up to date::\n\n    $ pip install exifread\n\nSee the `pip documentation <https://pip.pypa.io/en/latest/user_guide.html>`_ for more info.\n\nEXIF.py is mature software and strives for stability.\n\nDevelopment Version\n===================\n\nAfter cloning the repo, use the provided Makefile::\n\n  make venv install-all\n\nWhich will create a virtual environment and install development dependencies.\n\nUsage\n*****\n\nCommand line\n============\n\nSome examples::\n\n    EXIF.py image1.jpg\n    EXIF.py -dc image1.jpg image2.tiff\n    find ~/Pictures -name \"*.jpg\" -o -name \"*.tiff\" | xargs EXIF.py\n\nShow command line options::\n\n    EXIF.py -h\n\nPython Script\n=============\n\n.. code-block:: python\n\n    import exifread\n\n    # Open image file for reading (must be in binary mode)\n    with open(file_path, \"rb\") as file_handle:\n\n        # Return Exif tags\n        tags = exifread.process_file(file_handle)\n\n*Note:* To use this library in your project as a Git submodule, you should::\n\n    from <submodule_folder> import exifread\n\nReturned tags will be a dictionary mapping names of Exif tags to their\nvalues in the file named by ``file_path``.\nYou can process the tags as you wish. In particular, you can iterate through all the tags with:\n\n.. code-block:: python\n\n    for tag, value in tags.items():\n        if tag not in ('JPEGThumbnail', 'TIFFThumbnail', 'Filename', 'EXIF MakerNote'):\n            print(f\"Key: {tag}, value {value}\")\n\nAn ``if`` statement is used to avoid printing out a few of the tags that tend to be long or boring.\n\nThe tags dictionary will include keys for all of the usual Exif tags, and will also include keys for\nMakernotes used by some cameras, for which we have a good specification.\n\nNote that the dictionary keys are the IFD name followed by the tag name. For example::\n\n    'EXIF DateTimeOriginal', 'Image Orientation', 'MakerNote FocusMode'\n\n\nTag Descriptions\n****************\n\nTags are divided into these main categories:\n\n- ``Image``: information related to the main image (IFD0 of the Exif data).\n- ``Thumbnail``: information related to the thumbnail image, if present (IFD1 of the Exif data).\n- ``EXIF``: Exif information (sub-IFD).\n- ``GPS``: GPS information (sub-IFD).\n- ``Interoperability``: Interoperability information (sub-IFD).\n- ``MakerNote``: Manufacturer specific information. There are no official published references for these tags.\n\n\nProcessing Options\n******************\n\nThese options can be used both in command line mode and within a script.\n\nFaster Processing\n=================\n\nDon't process makernote tags, don't extract the thumbnail image (if any).\n\nPass the ``-q`` or ``--quick`` command line arguments, or as:\n\n.. code-block:: python\n\n    tags = exifread.process_file(\n        file_handle, details=False, extract_thumbnail=False\n    )\n\nTo process makernotes only, without extracting the thumbnail image (if any):\n\n.. code-block:: python\n\n    tags = exifread.process_file(\n        file_handle, details=True, extract_thumbnail=False\n    )\n\nTo extract the thumbnail image (if any), without processing makernotes:\n\n.. code-block:: python\n\n    tags = exifread.process_file(\n        file_handle, details=False, extract_thumbnail=True\n    )\n\nStop at a Given Tag\n===================\n\nTo stop processing the file after a specified tag is retrieved.\n\nPass the ``-t TAG`` or ``--stop-tag TAG`` argument, or as:\n\n.. code-block:: python\n\n    tags = exifread.process_file(file_handle, stop_tag='TAG')\n\nwhere ``TAG`` is a valid tag name without the IFD, ex ``'DateTimeOriginal'``.\n\n*The two above options are useful to speed up processing of large numbers of files.*\n\nStrict Processing\n=================\n\nReturn an error on invalid tags instead of silently ignoring.\n\nPass the ``-s`` or ``--strict`` argument, or as:\n\n.. code-block:: python\n\n    tags = exifread.process_file(file_handle, strict=True)\n\nBuilt-in Types\n==============\n\nFor easier serialization and programmatic use, this option returns a dictionary with values in built-in Python types\n(int, float, str, bytes, list, None) instead of `IfdTag` objects.\n\nPass the ``-b`` or ``--builtin`` argument, or as:\n\n.. code-block:: python\n\n    tags = exifread.process_file(file_handle, builtin_types=True)\n\nFor direct JSON serialization, combine this option with ``details=False`` to avoid bytes in the output:\n\n.. code-block:: python\n\n    json.dumps(exifread.process_file(file_handle, details=False, builtin_types=True))\n\nUsage Example\n=============\n\nThis example shows how to use the library to correct the orientation of an image\n(using Pillow for the transformation) before e.g. displaying it.\n\n.. code-block:: python\n\n    import exifread\n    from PIL import Image\n    import logging\n\n    def _read_img_and_correct_exif_orientation(path):\n        im = Image.open(path)\n        tags = {}\n        with open(path, \"rb\") as file_handle:\n            tags = exifread.process_file(file_handle, details=False)\n\n        if \"Image Orientation\" in tags:\n            orientation = tags[\"Image Orientation\"]\n            logging.basicConfig(level=logging.DEBUG)\n            logging.debug(\"Orientation: %s (%s)\", orientation, orientation.values)\n            val = orientation.values\n            if 2 in val:\n                val += [4, 3]\n            if 5 in val:\n                val += [4, 6]\n            if 7 in val:\n                val += [4, 8]\n            if 3 in val:\n                logging.debug(\"Rotating by 180 degrees.\")\n                im = im.transpose(Image.ROTATE_180)\n            if 4 in val:\n                logging.debug(\"Mirroring horizontally.\")\n                im = im.transpose(Image.FLIP_TOP_BOTTOM)\n            if 6 in val:\n                logging.debug(\"Rotating by 270 degrees.\")\n                im = im.transpose(Image.ROTATE_270)\n            if 8 in val:\n                logging.debug(\"Rotating by 90 degrees.\")\n                im = im.transpose(Image.ROTATE_90)\n        return im\n\n\nLicense\n*******\n\nCopyright \u00a9 2002-2007 Gene Cash\n\nCopyright \u00a9 2007-2025 Ianar\u00e9 S\u00e9vi and contributors\n\nA **huge** thanks to all the contributors over the years!\n\nOriginally written by Gene Cash & Thierry Bousch.\n\nAvailable as open source under the terms of the **BSD-3-Clause license**.\n\nSee the LICENSE file for details.\n",
    "bugtrack_url": null,
    "license": "\n        Copyright (c) 2002-2007 Gene Cash\n        Copyright (c) 2007-2025 Ianar\u00e9 S\u00e9vi and contributors\n        \n        Redistribution and use in source and binary forms, with or without\n        modification, are permitted provided that the following conditions\n        are met:\n        \n         1. Redistributions of source code must retain the above copyright\n            notice, this list of conditions and the following disclaimer.\n        \n         2. Redistributions in binary form must reproduce the above\n            copyright notice, this list of conditions and the following\n            disclaimer in the documentation and/or other materials provided\n            with the distribution.\n        \n         3. Neither the name of the authors nor the names of its contributors\n            may be used to endorse or promote products derived from this\n            software without specific prior written permission.\n        \n        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n        \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n        LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n        A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n        OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n        SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n        LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n        DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n        THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n        (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n        ",
    "summary": "Library to extract Exif information from digital camera image files.",
    "version": "3.3.2",
    "project_urls": {
        "Changelog": "https://github.com/ianare/exif-py/blob/master/ChangeLog.rst",
        "Repository": "https://github.com/ianare/exif-py"
    },
    "split_keywords": [
        "exif",
        " image",
        " metadata",
        " photo"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ef6f3ba3c792ee420a4fe467d19e01fb31bfe358641110baa2937573a620d3b2",
                "md5": "478f41d5c220029f039e72768646f9cb",
                "sha256": "f927cf4522827cc3ecfade8d0da37bbd5421f636eda7e650b61e9ce4c9a451fe"
            },
            "downloads": -1,
            "filename": "exifread-3.3.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "478f41d5c220029f039e72768646f9cb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 54340,
            "upload_time": "2025-07-17T21:24:04",
            "upload_time_iso_8601": "2025-07-17T21:24:04.005319Z",
            "url": "https://files.pythonhosted.org/packages/ef/6f/3ba3c792ee420a4fe467d19e01fb31bfe358641110baa2937573a620d3b2/exifread-3.3.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "06e4a1464fda6c9daac90d7d64ed4d5fc6e908896e0886326de23c923ddfbfce",
                "md5": "ca5a7973d8f0ad82c07bb3c87dfbc2c9",
                "sha256": "45c6a6564dd52e63a5d93c5e216fd65c38513b450167bee6d73183415db71358"
            },
            "downloads": -1,
            "filename": "exifread-3.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "ca5a7973d8f0ad82c07bb3c87dfbc2c9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 52029,
            "upload_time": "2025-07-17T21:24:05",
            "upload_time_iso_8601": "2025-07-17T21:24:05.508927Z",
            "url": "https://files.pythonhosted.org/packages/06/e4/a1464fda6c9daac90d7d64ed4d5fc6e908896e0886326de23c923ddfbfce/exifread-3.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-17 21:24:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ianare",
    "github_project": "exif-py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "exifread"
}
        
Elapsed time: 2.12177s