feat(metadata)!: migrate metadata stack to gamut-exif/gamut-icc/gamut-xmp - #44
Merged
Conversation
…-xmp Replaces little_exif with the gamut metadata family for all EXIF parse/build work, rebuilds the ICC internals on gamut-icc's typed model, adds XMP validation via gamut-xmp, and introduces the ImageMetadata <-> gamut_metadata::Metadata bridge. Decode side: ExifParser parses EXIF blobs via gamut_exif::Exif with the same tag-for-tag ImageMetadata mapping as before (camera, exposure, datetime, GPS, orientation), GPS via the typed GpsInfo plus direct gps_ifd reads for timestamp/datestamp/speed/direction, and the full extra-table mirror rebuilt by iterating every IFD's fields with typed Value conversion. little_exif walked whole containers itself, so blob-location scanners (JPEG APP1, PNG eXIf, WebP EXIF chunk, AVIF Exif item, TIFF whole-stream) are added as a documented transitional layer until each codec migration hands over codec-side MetadataBlock extraction. Encode side: ExifBuilder emits a gamut_exif::Exif (ISO now widens to LONG instead of truncating past u16); bare-TIFF bytes via ExifWriter. The JPEG append stays on img-parts (final removal rides with the JPEG migration, per the epic's carve-out). The AVIF/JXL appends were themselves little_exif calls, so they are replaced by rawshift-side box splicing in the pre-existing ICC/XMP style: a new metadata/isobmff.rs owns item insertion/extraction (infe + iloc + cdsc iref + mdat, patching existing extent offsets) shared by the EXIF and ICC paths. ICC: IccProfile keeps its public API but srgb() is now constructed from gamut-icc typed parts (ProfileHeader, TagData::Xyz with the identical s15Fixed16 constants, D50 PCS, gamma curve, desc/cprt) and serialized with to_bytes(); is_valid() delegates to gamut's parser. The old hand-rolled desc element was malformed textDescriptionType — the gamut-built profile is spec-valid, pinned by a new test parsing back colorants and TRC. XMP: append fns validate packets via XmpMeta::from_packet and reject malformed input (new XmpError::Invalid) instead of embedding garbage. Bridge: metadata/bridge.rs adds to_gamut/from_gamut between ImageMetadata and gamut_metadata::Metadata, with module docs enumerating exactly what does not survive to_gamut (DNG structs, sensor fields, extra table, makernote/iptc blobs). Round-trip unit tested. Deps: gamut-exif/gamut-metadata/gamut-xmp/gamut-icc added at the existing pin; little_exif dropped (lockfile also sheds brotli/crc). img-parts stays until the JPEG migration. Audit found no blocking gamut gaps; typed camera/DNG structs remain gamut#258. BREAKING CHANGE: ExifParser's container-format parameter is now the ExifContainer enum; EXIF built for embedding widens ISO to LONG.
This was referenced Jul 18, 2026
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.
Closes #19.
Stacked on #42 (base branch
18-core-gamut-reexports) — merge #42 first; GitHub will retarget this tomasterautomatically.What is Delivered
ExifParserparses blobs viagamut_exif::Exif, mapping tag-for-tag to the sameImageMetadatafields as before (camera, exposure, datetime, GPS incl. timestamp/speed/direction via directgps_ifdreads, orientation). Theextra-table mirror is rebuilt by iterating every IFD's fields with typedValueconversion — no more manual byte decoding. little_exif walked containers itself, so blob-location scanners (JPEG APP1 / PNGeXIf/ WebPEXIF/ AVIFExifitem / TIFF) are added as a documented transitional layer until each codec migration hands over codec-sideMetadataBlockextraction.gamut_exif::Exif(ISO now widens to LONG instead of truncating past u16); bare-TIFF bytes viaExifWriter. JPEG append stays on img-parts per the epic carve-out (final removal rides with Migrate JPEG to gamut #31).IccProfilekeeps its public API;srgb()is now constructed from typed parts (identical s15Fixed16 colorant constants, D50 PCS, gamma curve) and serialized viato_bytes();is_valid()delegates to gamut's parser. Bonus fix: the old hand-rolleddescelement was malformed textDescriptionType — the gamut-built profile is spec-valid, pinned by a test that parses back colorants and TRC.XmpError::Invalid) instead of embedding garbage.metadata/bridge.rswithto_gamut/from_gamutbetweenImageMetadataandgamut_metadata::Metadata; module docs enumerate exactly what does not surviveto_gamut(DNG structs, sensor fields,extra, makernote/iptc blobs). Round-trip tested.little_exifdropped (lockfile also sheds brotli/crc). One robustness win pinned in a test: a truncated EXIF stream now returns a structured error where little_exif panicked.Deviations from the issue text, with reasons
metadata/isobmff.rsowns ISOBMFF item insertion/extraction (infe + iloc +cdsciref + mdat with extent-offset patching), shared by the EXIF and ICC paths. This honors the full little_exif drop without a dual path. Verified end-to-end by the existingavif_exif_round_triptest against real encoder output.Gap audit (issue requirement)
No blocking gamut gaps found. Non-blocking notes: gamut-exif's typed
GpsInfois both-or-nothing on coordinate+hemisphere and can't distinguish an absentGPSAltitudeReffrom the 0 default — cosmetic, generic IFD access covers it. Typed camera/DNG structs remain gamut#258. MakerNote passthrough is covered upstream (opaque bytes + original-offset pinning by the writer).Verification Done
Run independently after the implementation (not just the implementer's own runs):
cargo test --workspace— 383 passed, 0 failedcargo test -p rawshift-image --features full— 566 passed, 0 failed (includesavif_exif_round_trip, the new ICC parse-back pin, XMP rejection tests, bridge round-trips)cargo test -p rawshift-image --features serde— 365 passed, 0 failedcargo clippy --workspace --all-targets -- -D warningsandcargo clippy -p rawshift-image --all-targets --features full -- -D warnings— both cleancargo fmt --all -- --check— clean; lefthook pre-commit greengrep little_exifacross manifests + lockfile — gone (one historical mention in a test comment documenting the panic little_exif had)