Skip to content

Add GPSHPositioningError to GPS IFD tag data - #9941

Merged
radarhere merged 3 commits into
python-pillow:mainfrom
dylanpulver:gps-hpositioningerror-tag-type
Sep 4, 2026
Merged

Add GPSHPositioningError to GPS IFD tag data#9941
radarhere merged 3 commits into
python-pillow:mainfrom
dylanpulver:gps-hpositioningerror-tag-type

Conversation

@dylanpulver

Copy link
Copy Markdown
Contributor

Changes proposed in this pull request:

  • Add 31: ("GPSHPositioningError", RATIONAL, 1) to the GPSInfoIFD entry of TiffTags._tags_v2_groups
  • Add a regression test asserting the emitted TIFF type for GPS tags 11 and 31

Exif 2.32 table 15 defines GPSHPositioningError (31) as RATIONAL, count 1. ExifTags.GPS already has it, but the GPS tag data added in #6661 stops at 30, so TiffTags.lookup(31, 34853).type is None and ImageFileDirectory_v2._setitem guesses the type from the Python value instead:

tag  value  on-wire type
 11  5.5    RATIONAL     <- GPSDOP, in the table
 11  5      RATIONAL
 31  5.5    DOUBLE       <- guessed
 31  5      SHORT

GPSDOP is the control here: same spec type and count, different result. piexif, checked separately, declares tag 31 as type 5 and writes type 5.

#6661 was opened for #6657, where GPS data written by Pillow was not readable in other programs, so this is the same table one entry further.

Rejected alternative: making the float branch of _setitem guess RATIONAL rather than DOUBLE fixes the float case but leaves the int case wrong, and it aborts Tests/test_file_libtiff.py::test_custom_metadata here.

Not changed, in case you want it separately: RelatedImageFileFormat, RelatedImageWidth and RelatedImageHeight are in ExifTags.Interop but not in the InteroperabilityIFD tag data. The types guessed for them are currently spec-legal, so nothing is written wrongly today.

macOS arm64, Python 3.12: python -m pytest Tests gives 5179 passed before and 5183 after, the +4 being the new parametrised cases, with the same single pre-existing failure both times (test_imagegrab.py::TestImageGrab::test_grab, screen recording permission on this machine). ruff 0.16.1 and black 26.5.1 clean on both files. Reverting only the table line fails the two tag-31 cases; the two tag-11 cases pass either way and are there as controls.

AI assistance: the diff, the test and this description were drafted by Claude Opus 5 working as a coding agent in this repository.

Exif 2.32 table 15 defines GPSHPositioningError (31) as RATIONAL with a
count of 1, and ExifTags.GPS already contains it, but it was missing from
the GPSInfoIFD entry in TiffTags. Without tag data, the type is guessed
from the Python value, so a float was written as DOUBLE and an int as
SHORT.
@radarhere radarhere added the 🤖-assisted AI-assisted label Sep 1, 2026
@radarhere

Copy link
Copy Markdown
Member

As an explanation for why this was missed, https://web.archive.org/web/20240428063145/https://www.awaresystems.be/imaging/tiff/tifftags/privateifd/gps.html doesn't mention this tag, but it was added in Exif 2.31.

@radarhere

Copy link
Copy Markdown
Member

I've created dylanpulver#1 with a suggestion.

Comment thread Tests/test_file_tiff_metadata.py Outdated
@radarhere
radarhere enabled auto-merge (squash) September 4, 2026 02:53
@radarhere radarhere changed the title Added GPSHPositioningError to GPS IFD tag data Add GPSHPositioningError to GPS IFD tag data Sep 4, 2026
@radarhere
radarhere merged commit 83f23d7 into python-pillow:main Sep 4, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖-assisted AI-assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants