feat(rawler): expose as-shot white balance temperature - #5
Open
dimafa wants to merge 1 commit into
Open
Conversation
dimafa
marked this pull request as ready for review
August 3, 2026 13:35
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.
Summary
Decoder::as_shot_temperaturefor retrieving as-shot white-balance temperature in KelvinColorTempAsShotvalue for CR2/CR3, with coefficient-based estimation as a fallbackMotivation
RapidRAW's Lightroom XMP sidecar importer needs the RAW file's as-shot temperature to convert custom Lightroom white balance using mired differences. Rawler already extracts the required native white-balance coefficients and calibration matrices, but did not expose their corresponding temperature.
Implementation
The
Decodertrait gains an optionalas_shot_temperaturemethod. Unsupported decoders returnNoneby default.For Canon CR2 and CR3 files, the decoder reads
ColorTempAsShotfrom the existing ColorData maker-note layouts and validates that it is within a plausible range. If it is absent or invalid, the decoder falls back to the shared estimator.For ARW, DNG, NEF, and NRW files, the estimator converts the camera neutral to CIE xy using the available color matrices. Dual-illuminant matrices are interpolated in reciprocal-temperature space, and correlated color temperature is calculated in CIE 1960 UCS space.
The value is exposed separately from
RawMetadata, avoiding changes to serialized metadata and the repository's existing sample snapshots.Validation
Passed with Rust 1.88.0 on macOS arm64:
cargo checkcargo build --all-featurescargo check --all-featuresu16; that unrelated temporary correction was revertedgit diff --checkThe unmodified repository's full
cargo testis currently blocked by a pre-existing test-only type inference error atrawler/src/tiles.rs:334: the vector is inferred asi32, whileSubPixelis implemented foru8,u16, andf32. The external sample database suite was not run becauseRAWLER_RAWDBwas unavailable.