Repository navigation
Description
While investigating the Sony colour issues discussed in #763 and the narrower fix in #732, I reviewed darktable’s RAW development pipeline. I’d like to discuss whether LightCraft should move towards camera calibration as the default colour foundation, while retaining embedded-JPEG matching as an optional appearance mode or fallback.
This is a proposal for an experiment and architectural discussion, rather than a request to immediately replace the existing pipeline.
Current behaviour
LightCraft already supports embedded colour matrices, per-model profiles and matrices derived from measured spectral sensitivities. However, for RAWs without an embedded matrix, an accepted fit to the camera JPEG can take precedence over the model’s spectral matrices.
The JPEG is used to estimate a transformation; LightCraft still renders pixels from the RAW sensor data. The concern is therefore scene-dependent colour estimation, rather than JPEG pixel replacement.
The current approach has understandable advantages: broad camera coverage and a starting appearance closer to the camera’s rendering. But a photograph containing mostly foliage, grey tones or one saturated colour gives limited evidence about the camera’s response elsewhere in colour space. Holding out pixels from that same image tests the fit within that scene; it does not establish consistency across other scenes or lighting.
The reference JPEG also contains the camera’s tone mapping, picture style, highlight treatment and potentially local adjustments. Matching it is a different objective from establishing a stable sensor-to-working-space conversion.
LightCraft’s current selection order
What prompted this proposal
In the darktable source reviewed, supported RAWs normally use a camera-specific input matrix/profile, with white balance and chromatic adaptation handled explicitly. Editing and display rendering then operate downstream of that input conversion.
Its normal RAW input-profile path does not estimate camera colour from each photograph’s embedded JPEG. This separation seems worth exploring in LightCraft, particularly because much of the matrix infrastructure already exists.
darktable input-profile defaults · White-balance/reference handling
Possible direction
Introduce an experimental calibrated rendering mode that:
- Uses valid embedded calibration or independently sourced, validated per-model calibration as its colour foundation.
- Keeps the base camera conversion independent of the embedded JPEG’s contents.
- Applies a separately defined default tone/rendering look, so calibration-first does not simply mean displaying an unfinished linear image.
- Offers camera-JPEG appearance matching separately, with the current estimation path retained for unsupported cameras.
- Exposes which calibration or fallback was used, making colour problems easier to diagnose.
The existing pooled JPEG-derived profiles would need an explicit role in this design. They should not automatically be treated as equivalent to measured calibration.
Suggested first experiment
Start with the Sony A7R IVA, for which LightCraft already has a spectral-matrix mapping, and compare:
- The current default rendering.
- A calibration-first conversion with a consistent default rendering look.
- Optional camera-look matching layered onto that calibrated basis.
Evaluate daylight and tungsten, with additional LED/mixed-light stress cases; include neutral surfaces, skin, foliage, saturated colours, low-colour scenes and clipped highlights.
Use independent chart/reference measurements where available, and assess camera-JPEG resemblance separately from colour accuracy. Darktable and Sony exports can provide useful visual comparisons, but neither should automatically be treated as ground truth.
Useful acceptance checks would include:
- Changing or removing only the embedded JPEG does not change the calibrated base conversion.
- Neutral balance and colour remain consistent across scenes.
- White-balance changes behave predictably.
- Preview and export agree under controlled colour-management settings.
- Existing edits retain their previous rendering unless explicitly migrated.
Calibration/profile versions would need to be preserved with edits; cache invalidation alone would not protect older work.
Scope and constraints
This would use an independent Rust implementation and appropriately licensed calibration data. It would not copy darktable/RawSpeed code, their camera tables, or Adobe profiles. The initial experiment would not require broad camera coverage or claim Lightroom parity.
Would this be a useful direction to explore? In particular, is JPEG-fit precedence intended as the long-term default, or primarily a bridge until broader camera calibration is available?
Activity
QuirkyTurtle94 commentedon Oct 12, 2026
Following up with a concrete source trace for the Sony A7R IV / IVA, and an important distinction between licensing and this project's policy.
Where darktable gets this calibration
RawSpeed's camera database contains a standard colour matrix for
ILCE-7RM4, withILCE-7RM4Aexplicitly listed as an alias. The same values are present in the commit that imported darktable'sadobe_coeff.cmatrices; its description identifies the intended DNGColorMatrix2/D65 representation and says the vendor is mostly Adobe. Camera database at that revision.Darktable's historical camera-support explanation also documents obtaining standard matrices through dcraw / Adobe DNG Converter output. That establishes a documented source chain; it is not evidence of a special Adobe permission granted exclusively to darktable.
Why “darktable can use it, but LightCraft legally cannot” would be too strong
The database itself is labelled CC-BY-SA 3.0, separately from the decoder's code licence. That licence permits reuse subject to its terms, including attribution and ShareAlike for adaptations. It would be wrong to treat the data as automatically GPL merely because RawSpeed distributes it, or to assume its licence notice alone resolves every upstream provenance question. Database licence · CC-BY-SA terms.
The definite blocker here is the current AGENTS.md policy: it explicitly prohibits copying Adobe camera matrices, even though its asset rules generally allow CC-BY-SA material. I haven't established a separate legal prohibition specific to LightCraft. Using numerical calibration data in an independent Rust implementation also would not, by itself, violate the pure-Rust requirement. Any change to the provenance policy would need a maintainer decision and an appropriate rights/licensing assessment; this comment isn't proposing to import the table.
There is already an independent route to test
LightCraft already has A7R IV calibration derived from Apache-2.0
rawtoaces-dataspectral measurements, plus an IVA alias: source and method, camera entry and aliases. The question is therefore also which calibration takes precedence, since an accepted JPEG-derived look can currently win.Would it make sense to start the proposed experiment with that existing calibration as the stable colour foundation, and a separate default tone/rendering look? Matching darktable's matrix alone would not match its finished image: white balance, chromatic adaptation, tone mapping and gamut handling also affect the result. Flatness and inaccurate hues should be evaluated separately.
good-news-everyone commentedon Oct 13, 2026
A data point for the proposed experiment from a second camera, and a sketch of how the choice could look in the app.
Nikon Z f: fit to the embedded JPEG vs the spectral matrix
The Z f has a spectral-matrix entry, but on every NEF I rendered with
LIGHTCRAFT_PROFILE=1the JPEG fit was accepted, so the spectral matrices never ran. There's no switch for the order, so to compare the two paths I overwrote the SOI marker of each embedded JPEG in a copy of the NEF (4 previews; the raw data is untouched). LightCraft 0.7.1 then reportscamera colour from spectral sensitivities: Nikon Z f. That is also the "removing only the embedded JPEG" check from the proposal above. Script:nef-strip-previews.py.Four frames, Picture Control Standard, Active D-Lighting off, base to high ISO, daylight and tungsten:
With the spectral render's exposure raised to match the fit's median luminance:
There's no reference here, so this says nothing yet about which is closer to the scene. That needs chart shots under daylight and tungsten. What it does show is the gap a calibration-first default would have to close with its own look and exposure. Without them, switching would just look darker and flatter, and the comparison would be about the look rather than colour.
How a switch could work
Where
Camera colour [Auto ▾] — fitted to the camera JPEGBeing a develop setting, it syncs, goes into presets, history and XMP, and is a normal control for the CLI and MCP.
calibrateprofiles.Modes
calibrateprofile, with colour and optionally tone fixed per modelWhat would keep it from being worse than today
ToneMap::display(JPEG strength), while raws without one use the raw path. On the same Z f, Highlights, Whites and Blacks reach 0–58% of Lightroom's response and Shadows 110–420% (Same Light-panel values render brighter/darker than Lightroom (Exposure, Whites/Blacks, Highlights/Shadows; worse for PV 11) #523 (comment)). If the mode also changes what Whites +50 means, edits won't transfer between modes.crs:CameraProfile"Adobe Standard" / "Adobe Color" to Colorimetric and "Camera Standard" / "Camera Neutral" to Camera, instead of only noting the name in the import warning.Related: #1310 / #1332 (provenance), #1063 (user DCPs), #1315 / #1342 (calibration UI), #523 (slider response).
good-news-everyone commentedon Oct 18, 2026
Two more Nikon Z f frames on 0.9.1, same method as above (a copy of the NEF with its embedded JPEGs disabled takes the spectral path). These two were shot with a custom Picture Control and Active D-Lighting Low, not Standard / off like the earlier set, which is worth keeping in mind for the JPEG-fit side.
The fit posterizes where the camera JPEG doesn't (DSC_4823)
At 100%, the camera's own embedded JPEG is smooth in the cat's fur and on the out-of-focus rug. The render fitted to that JPEG turns the same areas into flat patches with hard edges: the fur looks painted, and the blurred rug in the shadow breaks into blobs. The spectral render of the same raw is smooth there.
It isn't banding from quantisation: the 16-bit renders have tens of thousands of distinct levels in these crops on both paths. It looks like the symptom in #475 (Z 6II, "flat, hard-edged painted patches", closed without a linked fix). A likely contributor is the fitted tone curve for this frame (
LIGHTCRAFT_PROFILE=1, 32 knots). Between scene luminance 0.046 and 0.057 it rises at up to 3.6 stops out per stop in (output 0.12 → 0.22), right where the fur and the shaded rug sit, so small tonal differences there are stretched three- to fourfold. I haven't verified that this is the whole cause.The spectral render keeps more of the range
The spectral render's exposure was raised to match the fit's median luminance (+1.71 EV on DSC_4823, +0.98 EV on DSC_4824; 16-bit sRGB renders at 2000 px). The camera JPEG is the embedded full-size JPEG, resized to the same size. At the same mid-tone brightness the spectral render gives up less at both ends:
The camera JPEG is 8-bit, so its row counts 255 as clipped and ≤ 5 as near black; it's the nearest equivalent, not an exact one. Even so, the fit clips more of DSC_4823 than the JPEG it is fitted to.
Camera JPEG, fit to embedded JPEG and spectral matrix (exposure matched), each resampled once from full size (click for the full image):
All three come from the same sensor data, so this is the tone mapping rather than more dynamic range in the file. The camera JPEG and the curve fitted to it crush the shadow under the sofa and clip the sunlit chair, while the spectral path's default curve is flatter. For an editing base that's the more useful starting point (the range can be compressed later by the user), and it's one more argument for item 1 above: a calibrated base with its own fixed look, instead of a per-photo curve that can turn steep in exactly the tones a photo is made of.
wnanbei commentedon Oct 26, 2026
I'd like to add a practical use case for this feature, particularly for cameras with built-in LUT functionality, such as the Panasonic Lumix S9.
My workflow is to shoot RAW + JPEG with a custom Real Time LUT enabled in-camera.
Sometimes I like the LUT's appearance and only need minor adjustments. Other times, after reviewing the photos, I realize the LUT doesn't suit the image at all.
In those situations, I'd like a simple way to return the already-imported RAW photo to a neutral starting point, completely independent of the in-camera LUT's color grading and tone curve, so I can develop the image again from scratch.
Ideally, this would work as follows:
Keep the current camera-matched appearance as the default, preserving the existing workflow.
Provide a simple per-photo "Neutral RAW" or "Reset to Neutral RAW" option in the editing interface.
Allow switching between camera-matched and neutral RAW rendering at any time, without reimporting the photo.
Allow existing creative edits to be reset separately when starting over.
Ensure that neutral rendering does not derive creative color or tone adjustments from the embedded JPEG.
Support the Panasonic S9 and other cameras even when measured spectral calibration data is unavailable, using a suitable camera profile or neutral fallback where possible.
I understand that RAW data still requires demosaicing, white balance, and color-space conversion. By "neutral," I mean a rendering that does not inherit the camera's creative LUT or picture style, rather than completely unprocessed sensor data.
I'm not suggesting removing the existing camera JPEG matching feature. I simply want the freedom to decide after taking the photo whether to keep the in-camera LUT appearance or start RAW editing independently.
I noticed that PR #2222 is already working toward this functionality. I'm particularly interested in whether this workflow will also be available for the Panasonic S9.
Thanks for considering this!
LR-PROF-CAMERACOLOR-CHOICE: Calibrated camera colour, a per-photo cho…
FredApps commentedon Nov 9, 2026
Adding #3807: a Fujifilm X100T RAW+JPEG workflow needs an option to ignore the film-recipe look and start from a neutral render. The reporter notes that available per-photo proposals may still fall back to the JPEG fit on this body, so its missing calibration data needs consideration.
Gradivis commentedon Dec 3, 2026
+1. I shoot a Canon 5D Mk III for fine-art prints, and accurate, calibrated colour as the default starting point matters more to me than a punchy camera-JPEG look. An optional camera-matching look on top sounds right.