feat(tiff): Support GPS fields, and other metadata enhancements#5050
Open
lgritz wants to merge 7 commits intoAcademySoftwareFoundation:mainfrom
Open
feat(tiff): Support GPS fields, and other metadata enhancements#5050lgritz wants to merge 7 commits intoAcademySoftwareFoundation:mainfrom
lgritz wants to merge 7 commits intoAcademySoftwareFoundation:mainfrom
Conversation
Collaborator
Author
|
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>
Collaborator
Author
|
@kjellpeterson-shotover Are you able to tell if this patch satisfies your requirements as described in #5049 ? |
Contributor
There was a problem hiding this comment.
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.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.)