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

Added tag data for IFD groups #5554

Merged
merged 2 commits into from Jun 28, 2021
Merged

Conversation

radarhere
Copy link
Member

Resolves #5553

At the moment, our list of tag data is 1 dimensional. It doesn't account for the fact that tags actually exist in different groups - see https://exiftool.org/TagNames/EXIF.html

This PR adds TAGS_V2_GROUPS, which is used when the tag in question is part of a group.

#5553 mentions that the wrong type is used for InteropVersion, part of the InteropIFD. The type information for that tag is added here.

@kmilos
Copy link
Contributor

kmilos commented Jun 25, 2021

How is the possibility of a tag belonging to more than one group (==IFD?) handled?

For example, there is significant overlap between TIFF/EP and Exif tags, but in TIFF/EP they are part of the main image IFD0, while in Exif they are obviously part of ExifIFD.

@radarhere
Copy link
Member Author

This PR doesn't force the tags to be unique across groups, no.

When saving the data in tobytes(), the current tag is passed to ImageFileDirectory_v2.

ifd = ImageFileDirectory_v2(ifh, group=tag)

Then, when looking up the info of a tag, this PR retrieves info according to the group. If group is not None, then it doesn't retrieve from TAGS_V2, and if it is not, then it only pulls from the group.

if group is not None:
info = TAGS_V2_GROUPS[group].get(tag) if group in TAGS_V2_GROUPS else None
else:
info = TAGS_V2.get(tag)

So both IFD0 and EXIFIFD could have the same tag - which group is used comes from how the data is structured coming into tobytes().

@hugovk hugovk merged commit 2251be1 into python-pillow:master Jun 28, 2021
@radarhere radarhere deleted the tag_group_data branch June 28, 2021 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EXIF tag InteropVersion has wrong type
3 participants