Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inverse mappings for exif tags #6586

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 24 additions & 4 deletions docs/reference/ExifTags.rst
Expand Up @@ -4,25 +4,45 @@
:py:mod:`~PIL.ExifTags` Module
==============================

The :py:mod:`~PIL.ExifTags` module exposes two dictionaries which
The :py:mod:`~PIL.ExifTags` module exposes four dictionaries which
provide constants and clear-text names for various well-known EXIF tags.

.. py:data:: TAGS
:type: dict

The TAG dictionary maps 16-bit integer EXIF tag enumerations to
descriptive string names. For instance:
The TAGS dictionary maps 16-bit integer EXIF tag enumerations to
descriptive string names. For instance:

>>> from PIL.ExifTags import TAGS
>>> TAGS[0x010e]
'ImageDescription'

.. py:data:: TAG_CODES
:type: dict

The TAG_CODES dictionary maps descriptive string names to 16-bit integer EXIF
tag enumerations. For instance:

>>> from PIL.ExifTags import TAG_CODES
>>> TAG_CODES['ImageDescription']
0x010e

.. py:data:: GPSTAGS
:type: dict

The GPSTAGS dictionary maps 8-bit integer EXIF gps enumerations to
descriptive string names. For instance:
descriptive string names. For instance:

>>> from PIL.ExifTags import GPSTAGS
>>> GPSTAGS[20]
'GPSDestLatitude'

.. py:data:: GPS_CODES
:type: dict

The GPS_CODES dictionary maps descriptive string names to 8-bit integer EXIF
gps enumerations. For instance:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
gps enumerations. For instance:
GPS enumerations. For instance:


>>> from PIL.ExifTags import GPSTAGS
>>> GPS_CODES['GPSDestLatitude']
20
9 changes: 9 additions & 0 deletions src/PIL/ExifTags.py
Expand Up @@ -293,6 +293,12 @@
}
"""Maps EXIF tags to tag names."""

TAG_CODES = {
# possibly incomplete
tag_name: tag_code
for tag_code, tag_name in TAGS.items()
}
"""Maps tag names to EXIF tags."""

GPSTAGS = {
0: "GPSVersionID",
Expand Down Expand Up @@ -329,3 +335,6 @@
31: "GPSHPositioningError",
}
"""Maps EXIF GPS tags to tag names."""

GPS_CODES = {gps_name: gps_code for gps_code, gps_name in GPSTAGS.items()}
"""Maps tag names to EXIF GPS tags."""