Skip to content

Preserve JPEG XR image data when writing metadata - #9535

Open
wilx wants to merge 5 commits into
Exiv2:mainfrom
wilx:fix-jxr-metadata
Open

wilx wants to merge 5 commits into
Exiv2:mainfrom
wilx:fix-jxr-metadata

Conversation

@wilx

@wilx wilx commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #3162.

JPEG XR files previously went through the TIFF writer, which could discard compressed image data when rebuilding metadata. Add a private TIFF-based JPEG XR adapter that preserves image and alpha streams without decoding or recompression.

  • Ordinary edits affect the first non-preview image; explicit category clears apply across all images and previews.
  • Validate directory chains, stream ownership and protected fields, then verify temporary output before transfer. Direct TIFF writing rejects JPEG XR.
  • Preserve raw XMP without the toolkit; add regression tests and document support limits and the additive ImageType::jxr factory identity.

Validated on Linux: full serial debug CTest (8/8 groups), focused JXR/TIFF tests in debug, no-XMP, ASan/UBSan, Meson and BMFF/video-disabled builds, and the JXR CLI regression. Independent decoding and byte comparisons confirm stream preservation, including multiple images and both alpha layouts.

AI assistance: developed with OpenAI Codex.

Comment thread src/jxrimage_int.cpp Fixed
Comment thread src/jxrimage_int.cpp Fixed
Comment thread src/jxrimage_int.cpp Fixed
Comment thread src/jxrimage_int.cpp Fixed
Comment thread src/jxrimage_int.cpp Fixed
Comment thread src/jxrimage_int.cpp Fixed
Comment thread src/jxrimage_int.cpp Fixed
Comment thread src/jxrimage_int.cpp Fixed
@codecov

codecov Bot commented Nov 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.66534% with 82 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.86%. Comparing base (32c380d) to head (56ad36f).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/jxrimage_int.cpp 85.60% 25 Missing and 33 partials ⚠️
src/tiffvisitor_int.cpp 77.35% 2 Missing and 10 partials ⚠️
src/tiffimage.cpp 61.11% 1 Missing and 6 partials ⚠️
src/image.cpp 25.00% 1 Missing and 2 partials ⚠️
src/tiffimage_int.cpp 90.90% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9535      +/-   ##
==========================================
+ Coverage   65.28%   65.86%   +0.58%     
==========================================
  Files         117      118       +1     
  Lines       21859    22357     +498     
  Branches    10806    11104     +298     
==========================================
+ Hits        14270    14726     +456     
+ Misses       5324     5311      -13     
- Partials     2265     2320      +55     

☔ 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 added 5 commits November 22, 2026 16:24
Use a private TIFF-based JPEG XR adapter for primary-image metadata edits
and explicit category clears across image and preview directories. Validate
range ownership and protected fields, verify temporary output, and retain
compressed image and alpha streams. Reject direct TIFF writes to JPEG XR.

Fixes Exiv2#3162.
Cover multi-image edits, category clears, alpha streams, malformed layouts,
raw XMP copying, protected fields and failure-before-transfer behavior.
Register focused unit tests in CMake and Meson and add a CLI regression.

Fixes Exiv2#3162.
Explain primary-image edits, global category clears, protected fields,
raw XMP support and the additive ImageFactory JPEG XR identity.

Fixes Exiv2#3162.
Apply clang-format 20 to the TIFF reader member declarations so trailing comments remain aligned after adding JPEG XR validation state.
Replace indexed vector subscripts with at() when assembling image directories and verifying metadata, profiles, packets, and streams. Address the CodeQL unsafe-vector-access review findings.
@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.

JXR file is corrupted after writing metadata to image

2 participants