ExifRead


NameExifRead JSON
Version 3.0.0 PyPI version JSON
download
home_pagehttps://github.com/ianare/exif-py
SummaryRead Exif metadata from tiff and jpeg files.
upload_time2022-05-08 17:15:56
maintainer
docs_urlNone
authorIanaré Sévi
requires_python
licenseBSD
keywords exif image metadata photo
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            *******
EXIF.py
*******

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

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


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

EXIF.py is tested and officially supported on Python 3.5 to 3.10

Starting with version ``3.0.0``, Python2 compatibility is dropped *completely* (syntax errors due to type hinting).

https://pythonclock.org/


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 reqs-install

Which will install 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)
    f = open(path_name, 'rb')

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

*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 path_name.
You can process the tags as you wish. In particular, you can iterate through all the tags with:

.. code-block:: python

    for tag in tags.keys():
        if tag not in ('JPEGThumbnail', 'TIFFThumbnail', 'Filename', 'EXIF MakerNote'):
            print "Key: %s, value %s" % (tag, tags[tag])

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(f, details=False)

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(f, stop_tag='TAG')

where ``TAG`` is a valid tag name, 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(f, strict=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 f:
            tags = exifread.process_file(f, details=False)
        if "Image Orientation" in tags.keys():
            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

Credit
******

A huge thanks to all the contributors over the years!

Originally written by Gene Cash & Thierry Bousch.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ianare/exif-py",
    "name": "ExifRead",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "exif image metadata photo",
    "author": "Ianar\u00e9 S\u00e9vi",
    "author_email": "ianare@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/20/64/e8f40966ca766173fe57cc4de7d35492cf18949ced8b612924d48fa1d297/ExifRead-3.0.0.tar.gz",
    "platform": null,
    "description": "*******\nEXIF.py\n*******\n\nEasy to use Python module to extract Exif metadata from digital image files.\n\nSupported formats: TIFF, JPEG, PNG, Webp, HEIC\n\n\nCompatibility\n*************\n\nEXIF.py is tested and officially supported on Python 3.5 to 3.10\n\nStarting with version ``3.0.0``, Python2 compatibility is dropped *completely* (syntax errors due to type hinting).\n\nhttps://pythonclock.org/\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 reqs-install\n\nWhich will install 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    # Open image file for reading (must be in binary mode)\n    f = open(path_name, 'rb')\n\n    # Return Exif tags\n    tags = exifread.process_file(f)\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 path_name.\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 in tags.keys():\n        if tag not in ('JPEGThumbnail', 'TIFFThumbnail', 'Filename', 'EXIF MakerNote'):\n            print \"Key: %s, value %s\" % (tag, tags[tag])\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(f, details=False)\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(f, stop_tag='TAG')\n\nwhere ``TAG`` is a valid tag name, 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(f, strict=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 f:\n            tags = exifread.process_file(f, details=False)\n        if \"Image Orientation\" in tags.keys():\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\nCredit\n******\n\nA huge thanks to all the contributors over the years!\n\nOriginally written by Gene Cash & Thierry Bousch.",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Read Exif metadata from tiff and jpeg files.",
    "version": "3.0.0",
    "split_keywords": [
        "exif",
        "image",
        "metadata",
        "photo"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dbd6189b0016ae8995ad94cd6e2573baf0c289ff862996821d4e42eb6a0206e3",
                "md5": "ef2d74c219e512440fb100879d4f39db",
                "sha256": "2c5c59ef03b3bbee75b82b82d2498006b3c13509f35c9a76c7552faff73fa2d5"
            },
            "downloads": -1,
            "filename": "ExifRead-3.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ef2d74c219e512440fb100879d4f39db",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 40428,
            "upload_time": "2022-05-08T18:39:38",
            "upload_time_iso_8601": "2022-05-08T18:39:38.175975Z",
            "url": "https://files.pythonhosted.org/packages/db/d6/189b0016ae8995ad94cd6e2573baf0c289ff862996821d4e42eb6a0206e3/ExifRead-3.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2064e8f40966ca766173fe57cc4de7d35492cf18949ced8b612924d48fa1d297",
                "md5": "4804e890da40a3b336f12574e9a5a7d6",
                "sha256": "0ac5a364169dbdf2bd62f94f5c073970ab6694a3166177f5e448b10c943e2ca4"
            },
            "downloads": -1,
            "filename": "ExifRead-3.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4804e890da40a3b336f12574e9a5a7d6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 39895,
            "upload_time": "2022-05-08T17:15:56",
            "upload_time_iso_8601": "2022-05-08T17:15:56.122432Z",
            "url": "https://files.pythonhosted.org/packages/20/64/e8f40966ca766173fe57cc4de7d35492cf18949ced8b612924d48fa1d297/ExifRead-3.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-05-08 17:15:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "ianare",
    "github_project": "exif-py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "exifread"
}
        
Elapsed time: 0.03569s