Skip to content

Preserve TIFF SubIFD image order when rewriting metadata - #9540

Open
wilx wants to merge 1 commit into
Exiv2:mainfrom
wilx:fix-tiff-image-offsets
Open

wilx wants to merge 1 commit into
Exiv2:mainfrom
wilx:fix-tiff-image-offsets

Conversation

@wilx

@wilx wilx commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

A metadata rewrite can leave TIFF/DNG image offsets pointing at the wrong payloads because transform_reduce can emit SubIFD image data out of order. Replace it with an ordered loop so payloads follow the assigned offsets.

Add generated regressions for strips/tiles, both byte orders, child-count boundaries, repeated edits, and fresh serialization.

Validated debug, release, no-XMP, ASan/UBSan, and Meson builds; full debug CTest passes 8/8 suites. All 688 image streams in the reproducing DNG retain their original bytes at the recorded offsets.

Found while investigating #2913; this fix is independent of #9539.

AI assistance: OpenAI Codex assisted with implementation, tests, and this description.

@codecov

codecov Bot commented Oct 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.08%. Comparing base (a9aa1b7) to head (7913815).
⚠️ Report is 16 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9540      +/-   ##
==========================================
+ Coverage   65.00%   65.08%   +0.07%     
==========================================
  Files         117      117              
  Lines       21834    21834              
  Branches    10777    10778       +1     
==========================================
+ Hits        14194    14211      +17     
+ Misses       5377     5364      -13     
+ Partials     2263     2259       -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wilx
wilx force-pushed the fix-tiff-image-offsets branch 2 times, most recently from f986d69 to 8629e5a Compare November 4, 2026 23:15
Image payloads were emitted through transform_reduce, which can evaluate
SubIFDs out of order. Recorded offsets could then point at another image's
payload after a metadata rewrite.

Write child image data in directory order and add generated TIFF
regressions covering metadata edits and fresh serialization.

Discovered while investigating Exiv2#2913; independent of the Sony metadata fix.
@wilx
wilx force-pushed the fix-tiff-image-offsets branch from 8629e5a to a5c74d7 Compare November 22, 2026 15:24
@mergify

mergify Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request once it meets the queue conditions

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.

1 participant