Skip to content

feat(tiff): Support GPS fields, and other metadata enhancements#5050

Open
lgritz wants to merge 7 commits intoAcademySoftwareFoundation:mainfrom
lgritz:lg-gps
Open

feat(tiff): Support GPS fields, and other metadata enhancements#5050
lgritz wants to merge 7 commits intoAcademySoftwareFoundation:mainfrom
lgritz:lg-gps

Conversation

@lgritz
Copy link
Collaborator

@lgritz lgritz commented Feb 18, 2026

Most visible change: The TIFF reader and writer now correctly handle GPS tags.

Fixes #5049

But along the way, and to get it completely right, a fairly extensive refactoring of our TIFF tag handling was needed. The libtiff behavior around different tags is extremely convoluted, and there were a bunch of cases we either didn't handle correctly, or were dropping on the floor. So there are also some other non-GPS tags that we missed all along but now read properly.

Note that the support for separate IFDs for GPS tags is only supported via the API in libtiff 4.2 and newer, so this is disabled when bulding against older libtiff versions. (Our support of old libtiff versions extends extraordinarily far back in time.)

@lgritz
Copy link
Collaborator Author

lgritz commented Feb 19, 2026

The failures on the wheel builds are unrelated to this PR and are happening in main. We are investigating that separately, and it should not inhibit review and acceptance of this PR.

Most visible change: The TIFF reader and writer now correctly handle
GPS tags.

Fixes 5049

But along the way, and to get it completely right, a fairly extensive
refactoring of our TIFF tag handling was needed. The libtiff behavior
around different tags is extremely convoluted, and there were a bunch
of cases we either didn't handle correctly, or were dropping on the
floor. So there are also some other non-GPS tags that we missed all
along but now read properly.

Note that the support for separate IFDs for GPS tags is only supported
via the API in libtiff 4.2 and newer, so this is disabled when bulding
against older libtiff versions. (Our support of old libtiff versions
extends extraordinarily far back in time.)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
@lgritz
Copy link
Collaborator Author

lgritz commented Feb 27, 2026

@kjellpeterson-shotover Are you able to tell if this patch satisfies your requirements as described in #5049 ?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds proper TIFF GPS IFD read/write support (when building against libtiff ≥ 4.2) and refactors TIFF tag handling to preserve more Exif/TIFF metadata that was previously ignored or dropped.

Changes:

  • Write GPS tags into a dedicated GPS IFD (libtiff ≥ 4.2) and read them back via TIFFTAG_GPSIFD scanning.
  • Generalize TIFF tag extraction to correctly handle more libtiff field passing conventions (including multi-value fields like YCbCrSubsampling and PageNumber).
  • Extend tests: add a GPS-tagged TIFF fixture and update reference outputs to reflect newly preserved metadata.

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
testsuite/tiff-suite/ref/out.txt Updates golden output to include newly detected Exif/TIFF fields (e.g., ISO, PhotographicSensitivity, YCbCrSubsampling, PageNumber).
testsuite/tiff-suite/ref/out-jpeg9d-alt.txt Same as above for jpeg9d-alt baseline.
testsuite/tiff-suite/ref/out-jpeg9b.txt Same as above for jpeg9b baseline.
testsuite/tiff-suite/ref/out-alt2.txt Same as above for alt2 baseline.
testsuite/tiff-suite/ref/out-alt.txt Same as above for alt baseline.
testsuite/tiff-misc/src/gps.tif Adds a GPS metadata fixture TIFF for round-trip testing.
testsuite/tiff-misc/run.py Adds a GPS read/write test and info dump of the round-tripped output.
testsuite/tiff-misc/ref/out.txt Updates baseline for older libtiff variants (no GPS IFD support).
testsuite/tiff-misc/ref/out-libtiff430.txt Updates baseline for libtiff 4.3+ to include GPS tag output.
testsuite/tiff-misc/ref/out-libtiff410.txt Updates baseline for libtiff 4.1 (no GPS IFD support).
testsuite/tiff-misc/ref/out-libtiff403.txt Updates baseline for libtiff 4.0.3 (no GPS IFD support).
testsuite/tiff-misc/ref/out-libtiff403-c.txt Updates baseline variant for libtiff 4.0.3-c (no GPS IFD support).
testsuite/tiff-misc/ref/out-libtiff403-b.txt Updates baseline variant for libtiff 4.0.3-b (no GPS IFD support).
testsuite/tiff-misc/ref/out-libiff470.txt Adds a new libtiff 4.7-specific baseline variant.
testsuite/misnamed-file/ref/out.txt Updates golden output to include tiff:PageNumber.
src/tiff.imageio/tiffoutput.cpp Refactors Exif writing to support GPS IFD writing and shared directory-writing helper.
src/tiff.imageio/tiffinput.cpp Refactors tag reading to handle more libtiff calling conventions; adds GPS IFD scanning.
src/libOpenImageIO/exif.cpp Fixes Exif:YCbCrSubsampling count and adds gps_tag_lookup implementation.
src/include/OpenImageIO/tiffutils.h Exposes gps_tag_lookup in the public API.
src/cmake/externalpackages.cmake Recommends libtiff ≥ 4.2 to unlock GPS IFD support.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

lgritz and others added 6 commits March 1, 2026 12:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
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.

bug: OpenImageIO is not able to write GPS tags to tiff files

2 participants