Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
366b1d2
LR-PROF-IMPORT: import the user's own DNG camera profiles (.dcp)
OneSlips Oct 11, 2026
1ecfb7b
Merge upstream main into pr/dcp-camera-profiles
OneSlips Oct 13, 2026
4a5ef6f
LR-PROF-IMPORT: build against upstream main (kelvin_presets, 3-arg lo…
OneSlips Oct 13, 2026
ba03cfe
LR-PROF-IMPORT: hover previews and browser thumbnails develop the hov…
OneSlips Oct 13, 2026
d1cfbc7
Merge upstream main into pr/dcp-camera-profiles
OneSlips Oct 15, 2026
c8c9904
LR-PROF-IMPORT: build against upstream main (face-tile test loader an…
OneSlips Oct 15, 2026
50044cd
Merge upstream main into pr/dcp-camera-profiles
OneSlips Oct 15, 2026
96e46fc
CI: the catalog's staging-link test module is Unix-only (unused impor…
OneSlips Oct 15, 2026
d1313b7
CI: same-folder export test expects the '/'-joined subfolder (failed …
OneSlips Oct 15, 2026
af265c5
CI: folder-drop tests build widget ids with the Folders tree's '/' pa…
OneSlips Oct 15, 2026
cb20494
LR-PROF-IMPORT: rustfmt after merging main
OneSlips Oct 15, 2026
a38bb76
LR-PROF-IMPORT: merge origin/main
OneSlips Oct 21, 2026
f911c7d
LR-PROF-IMPORT: a real D750 camera profile as a pinned test corpus, c…
OneSlips Oct 21, 2026
0d17a38
LR-PROF-IMPORT: a single .dcp file is a camera profile only, not also…
OneSlips Oct 15, 2026
2128b3f
LR-PROF-IMPORT: merge origin/main
OneSlips Oct 21, 2026
49f2ec4
LR-PROF-IMPORT: merge origin/main (31ee2643, round-2 integration)
OneSlips Oct 22, 2026
af38d04
LR-PROF-IMPORT: review fixes for imported camera profiles
OneSlips Oct 23, 2026
4ef025d
LR-PROF-IMPORT: merge origin/main (23e18128, release 0.13.0)
OneSlips Oct 23, 2026
7d616d6
LR-PROF-IMPORT: merge origin/main (98702b5c, integration batch 43)
OneSlips Oct 23, 2026
4694624
LR-PROF-IMPORT: smart previews without the camera profile, current-pr…
OneSlips Oct 23, 2026
91f08f4
Merge remote-tracking branch 'origin/main' into pr/dcp-camera-profiles
OneSlips Oct 24, 2026
42c414d
LR-PROF-IMPORT: the Before side decodes with its own camera profile; …
OneSlips Oct 24, 2026
a3c82f9
LR-PROF-IMPORT: a cached smart preview stands in while the original i…
OneSlips Oct 25, 2026
a670d64
LR-PROF-IMPORT: merge origin/main (31ec62cd)
OneSlips Oct 25, 2026
c94484c
Merge remote-tracking branch 'origin/main' into pr/dcp-camera-profiles
OneSlips Oct 25, 2026
865c914
Merge remote-tracking branch 'origin/main' into pr/dcp-camera-profiles
OneSlips Oct 26, 2026
7dac66e
LR-PROF-IMPORT: deleting a camera profile removes the library's copy …
OneSlips Oct 26, 2026
c739b7b
LR-PROF-IMPORT: deleting a camera profile never follows `..` out of t…
OneSlips Oct 26, 2026
3c16bcd
LR-PROF-IMPORT: merge main (upstream file split)
OneSlips Oct 27, 2026
d7eb0ef
LR-PROF-IMPORT: both tone fits of a DNG see its lens opcodes; no side…
OneSlips Oct 27, 2026
5a3d647
LR-PROF-IMPORT: a hover preview's key carries the camera profile file…
OneSlips Oct 27, 2026
c29f618
LR-PROF-IMPORT: merge main (59a5d00c6, the ui-egui split and clippy s…
OneSlips Oct 28, 2026
3e19238
LR-PROF-IMPORT: merge main (e381c1ae6, Release 0.15.0)
OneSlips Oct 28, 2026
3bca86f
LR-PROF-IMPORT: merge main (e2d18b5fb, flatpak network access #3269)
OneSlips Oct 28, 2026
e68f7bb
LR-PROF-IMPORT: merge main (integration batch 45)
OneSlips Oct 30, 2026
4a30283
Merge remote-tracking branch 'origin/main' into pr/dcp-camera-profiles
OneSlips Oct 31, 2026
32d3a7e
LR-PROF-IMPORT: unusable camera profiles not offered; file's WB scale…
OneSlips Oct 31, 2026
46c9d82
Merge remote-tracking branch 'origin/main' into pr/dcp-camera-profiles
OneSlips Oct 31, 2026
e074555
LR-PROF-IMPORT: one Camera Profiles group; the web loader keeps a raw…
OneSlips Oct 31, 2026
b9937f7
LR-PROF-IMPORT: camera profile files are read at most to the 64 MiB l…
OneSlips Oct 31, 2026
408636a
LR-PROF-IMPORT: a test that a hostile hue/saturation map header in a …
OneSlips Nov 1, 2026
3cb0d3b
Merge main; cache keys keep both the camera profile and the lens profile
FredApps Nov 5, 2026
a864aad
Docs: parity checklist keeps both sides of the merge
FredApps Nov 5, 2026
b295a55
LR-PROF-IMPORT: tests added on main take the file loader's camera-pro…
FredApps Nov 5, 2026
04b7054
Merge main; tracker docs keep both sides
FredApps Nov 5, 2026
9b049d0
Merge remote-tracking branch 'origin/main' into HEAD
FredApps Nov 5, 2026
9f8b3f5
Merge main; a thumbnail test takes the file loader's camera-profile a…
FredApps Nov 5, 2026
ed7508f
Docs: one camera colour row, with main's notes and the import note
FredApps Nov 5, 2026
d696b8a
Merge remote-tracking branch 'origin/main' into HEAD
FredApps Nov 5, 2026
1261048
Merge main; cache keys hold the process, camera profile and lens
FredApps Nov 5, 2026
32a9b05
Process key tests take the profile salt argument
FredApps Nov 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/lightcraft-web/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use std::collections::HashMap;
use std::sync::{Arc, Mutex};

use lightcraft_engine::files::{load_bytes, probe_bytes};
use lightcraft_engine::files::{load_bytes_with, probe_bytes};
use lightcraft_engine::media::{FileLoader, FileProbe};

/// Prefix of the catalog paths of files kept in browser storage.
Expand Down Expand Up @@ -144,9 +144,9 @@ impl Originals {
/// Engine hooks that decode/probe from memory.
pub fn hooks(&self) -> (FileLoader, FileProbe) {
let s = self.clone();
let loader: FileLoader = Arc::new(move |path: &str, max_edge: usize| {
let loader: FileLoader = Arc::new(move |path: &str, max_edge: usize, dcp: Option<&lightcraft_engine::media::DcpProfile>| {
let bytes = s.get(path).ok_or_else(|| format!("{path}: the original is still loading from browser storage"))?;
load_bytes(&bytes, max_edge)
load_bytes_with(&bytes, max_edge, dcp)
});
let s = self.clone();
let probe: FileProbe = Arc::new(move |path: &str| {
Expand Down
4 changes: 2 additions & 2 deletions crates/catalog/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,13 @@ impl Store for MemStore {
}
}

#[cfg(test)]
// (its one test plants a symlink, so the module is Unix-only: elsewhere `use super::*` would be unused)
#[cfg(all(test, unix))]
mod tests_staging {
use super::*;

/// A link planted at a staging name (`<name>.tmp`) is removed, never followed: the file it points to keeps its
/// bytes and the save still lands (issue #1502).
#[cfg(unix)]
#[test]
fn a_link_at_the_staging_name_is_never_written_through() {
let dir = std::env::temp_dir().join(format!("lc-staging-link-{}", std::process::id()));
Expand Down
2 changes: 1 addition & 1 deletion crates/engine/examples/render_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ fn main() {
}
println!(" {:<36} {}", "load_bytes(2560):", best(n, || drop(lightcraft_engine::files::load_bytes(&bytes, 2560).expect("load"))));
let (loader, _) = lightcraft_engine::files::fs_hooks();
println!(" {:<36} {}", "fs loader (2560, read+load):", best(n, || drop(loader(path, 2560).expect("load"))));
println!(" {:<36} {}", "fs loader (2560, read+load):", best(n, || drop(loader(path, 2560, None).expect("load"))));
}
return;
}
Expand Down
175 changes: 175 additions & 0 deletions crates/engine/src/cmd/dcp_profiles.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
//! Imported camera profiles: the user's own DNG Camera Profiles (`.dcp`), chosen like any other
//! profile (`develop.profile {id: "dcp:…"}`). Unlike the built-in looks and LUT profiles, which
//! work on developed colour, a camera profile replaces the raw file's colour model when it is
//! decoded (its matrices and hue/saturation map; see [`lightcraft_raw::dcp`]), so the photo's
//! source is decoded again when it changes. Other photos (JPEG, TIFF…) ignore it.
//!
//! A library on disk keeps a copy of each file in its `Profiles/` folder; the list lives in the
//! library's prefs and the profiles are parsed again when the library opens.

use std::path::{Path, PathBuf};
use std::sync::Arc;

use lightcraft_raw::dcp::DcpProfile;
use serde_json::{Value, json};

use super::{CommandSpec, always, bad, cmd, str_param};
use crate::{Result, Session};

/// Profile id prefix of imported camera profiles.
pub const DCP_PREFIX: &str = "dcp:";
/// Profile browser group of imported camera profiles.
pub const DCP_GROUP: &str = "Camera Profiles";

/// One imported camera profile.
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DcpEntry {
/// `dcp:<slug>`.
pub id: String,
/// `ProfileName`, else the file name.
pub name: String,
/// The camera it was made for (`UniqueCameraModel`).
#[serde(default)]
pub camera_model: String,
/// The `.dcp` file (the library's copy when there is a library on disk).
pub file: String,
}

/// Is `id` an imported camera profile id?
pub fn is_dcp_id(id: &str) -> bool {
id.starts_with(DCP_PREFIX)
}

fn profiles_dir(s: &Session) -> Option<PathBuf> {
s.library.as_ref().filter(|l| l.on_disk).map(|l| l.dir.join("Profiles"))
}

/// Parse every imported camera profile again and hand them to the decoder (missing or damaged
/// files are skipped: photos using them develop with the file's own colour).
pub fn register_all(s: &mut Session) {
let loaded: Vec<(String, Arc<DcpProfile>)> = s
.dcp_profiles
.iter()
.filter_map(|p| std::fs::read(&p.file).ok().and_then(|b| lightcraft_raw::dcp::parse_dcp(&b).ok()).map(|d| (p.id.clone(), Arc::new(d))))
.collect();
s.media.camera_profiles = loaded.into_iter().collect();
}

/// `.dcp` files under `paths` (folders searched).
pub fn dcp_files(paths: &[String]) -> Vec<PathBuf> {
let is_dcp = |f: &Path| f.extension().is_some_and(|x| x.eq_ignore_ascii_case("dcp"));
let mut out = Vec::new();
for p in paths {
let path = Path::new(p);
if path.is_dir() {
out.extend(crate::walk::files_in(path, None, crate::walk::Limits::default(), is_dcp).files);
} else if is_dcp(path) {
out.push(path.to_path_buf());
}
}
out
}

/// Import the `.dcp` files under `paths` → (imported `[{id, name, cameraModel}]`, failed `[[file, error]]`).
/// A profile already imported (same name, camera and bytes) is not added twice.
pub fn import_files(s: &mut Session, paths: &[String]) -> Result<(Vec<Value>, Vec<Value>)> {
const C: &str = "profile.import";
let dir = profiles_dir(s);
if let Some(d) = &dir {
std::fs::create_dir_all(d).map_err(|e| bad(C, format!("{}: {e}", d.display())))?;
}
let (mut imported, mut failed) = (Vec::new(), Vec::new());
for f in dcp_files(paths) {
let shown = f.display().to_string();
let bytes = match std::fs::read(&f) {
Ok(b) => b,
Err(e) => {
failed.push(json!([shown, e.to_string()]));
continue;
}
};
let profile = match lightcraft_raw::dcp::parse_dcp(&bytes) {
Ok(p) => p,
Err(e) => {
failed.push(json!([shown, e.to_string()]));
continue;
}
};
let stem = f.file_stem().map(|n| n.to_string_lossy().to_string()).unwrap_or_else(|| "Camera Profile".into());
let name = if profile.name.trim().is_empty() { stem.clone() } else { profile.name.trim().to_string() };
// the same profile imported again: keep the one there is
let same = s
.dcp_profiles
.iter()
.find(|p| p.name == name && p.camera_model == profile.camera_model && std::fs::read(&p.file).is_ok_and(|b| b == bytes));
if let Some(p) = same {
imported.push(json!({"id": p.id, "name": p.name, "cameraModel": p.camera_model, "existing": true}));
continue;
}
// (the file name keeps profiles with the same ProfileName apart, e.g. per-body copies)
let slug = crate::presets::slug(&format!("{}-{stem}", profile.camera_model));
let mut id = format!("{DCP_PREFIX}{slug}");
let mut n = 2;
while s.dcp_profiles.iter().any(|x| x.id == id) {
id = format!("{DCP_PREFIX}{slug}-{n}");
n += 1;
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
let file = match &dir {
Some(d) => {
let to = d.join(format!("{}.dcp", id.trim_start_matches(DCP_PREFIX)));
std::fs::write(&to, &bytes).map_err(|e| bad(C, format!("{}: {e}", to.display())))?;
to.to_string_lossy().to_string()
}
// no library on disk: remember the original (the in-memory session ends with the app)
None => f.to_string_lossy().to_string(),
};
s.media.camera_profiles.insert(id.clone(), Arc::new(profile.clone()));
s.dcp_profiles.push(DcpEntry { id: id.clone(), name: name.clone(), camera_model: profile.camera_model.clone(), file });
imported.push(json!({"id": id, "name": name, "cameraModel": profile.camera_model}));
}
Ok((imported, failed))
}

fn delete(s: &mut Session, p: &Value) -> Result<Value> {
const C: &str = "profile.deleteCamera";
let id = str_param(p, "id").ok_or_else(|| bad(C, "missing id"))?.to_string();
let Some(i) = s.dcp_profiles.iter().position(|x| x.id == id) else {
return Err(bad(C, format!("no imported camera profile `{id}`")));
};
let entry = s.dcp_profiles.remove(i);
s.media.camera_profiles.remove(&id);
// the library's copy goes; a file outside the library is the user's and stays
if let Some(d) = profiles_dir(s)
&& Path::new(&entry.file).starts_with(&d)
{
let _ = std::fs::remove_file(&entry.file);
}
s.profile_favorites.retain(|f| f != &id);
s.profile_recent.retain(|f| f != &id);
s.save_prefs()?;
Ok(json!({"deleted": id}))
}

pub fn specs() -> Vec<CommandSpec> {
vec![
cmd!(
query "profiles.camera",
"Imported Camera Profiles",
[],
None,
"{} → {profiles: [{id, name, cameraModel, file}]}: the imported .dcp camera profiles (use with develop.profile)",
always,
|s, _| Ok(json!({"profiles": s.dcp_profiles}))
),
cmd!(
"profile.deleteCamera",
"Delete Imported Camera Profile",
[],
None,
"{id: dcp:…} — photos using it develop with their file's own colour again",
always,
delete
),
]
}
5 changes: 4 additions & 1 deletion crates/engine/src/cmd/develop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,10 @@ pub fn specs() -> Vec<CommandSpec> {
}),
cmd!("develop.profile", "Set Profile", [], None, "{id: profile id (see profiles.list), amount?: 0..200}", has_active, |s, p| {
let id = str_param(p, "id").ok_or_else(|| bad("develop.profile", "missing id"))?.to_string();
if !crate::presets::PROFILES.iter().any(|x| x.id == id) && !s.lut_profiles.iter().any(|x| x.id == id) {
if !crate::presets::PROFILES.iter().any(|x| x.id == id)
&& !s.lut_profiles.iter().any(|x| x.id == id)
&& !s.dcp_profiles.iter().any(|x| x.id == id)
{
return Err(bad("develop.profile", format!("unknown profile `{id}`")));
}
edit(s, "develop.profile", "Profile", |d| {
Expand Down
14 changes: 11 additions & 3 deletions crates/engine/src/cmd/lut_profiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ fn cube_files(paths: &[String]) -> (Vec<(String, String, Option<String>)>, Vec<V
));
}
}
} else {
} else if path.extension().is_some_and(|x| x.eq_ignore_ascii_case("cube")) {
match std::fs::read_to_string(path) {
Ok(t) => out.push((stem(path), t, None)),
Err(e) => failed.push(json!([stem(path), e.to_string()])),
}
}
// (a .dcp is a camera profile: `dcp_profiles::import_files` takes it)
}
(out, failed)
}
Expand Down Expand Up @@ -134,6 +135,10 @@ fn import(s: &mut Session, p: &Value) -> Result<Value> {
s.lut_profiles.push(LutProfile { id: id.clone(), name: display.clone(), group: group.clone(), file });
imported.push(json!({"id": id, "name": display, "group": group}));
}
// camera profiles (.dcp) among them
let (cameras, camera_failed) = super::dcp_profiles::import_files(s, &paths)?;
imported.extend(cameras);
failed.extend(camera_failed);
s.save_prefs()?;
// presets that name these profiles use them now
crate::profile_refs::refresh(s);
Expand All @@ -147,12 +152,15 @@ pub fn specs() -> Vec<CommandSpec> {
"Import Profiles",
[],
None,
"{paths: [.cube file, folder or .zip]} — 3D LUTs become creative profiles (Amount 0–200 %; rendered on the CPU) in the profile browser's groups (folder / zip name, else Imported) → {imported: [{id, name, group}], failed}",
"{paths: [.cube / .dcp file, folder or .zip]} — 3D LUTs become creative profiles (Amount 0–200 %; rendered on the CPU) in the profile browser's groups (folder / zip name, else Imported); DNG camera profiles (.dcp, the user's own) become camera profiles (dcp: ids, group Camera Profiles) that replace a raw file's colour model when it is decoded → {imported: [{id, name, group | cameraModel}], failed}",
always,
import
),
cmd!("profile.deleteImported", "Delete Imported Profile", [], None, "{id: lut:…}", always, |s, p| {
cmd!("profile.deleteImported", "Delete Imported Profile", [], None, "{id: lut:… | dcp:…}", always, |s, p| {
let id = str_param(p, "id").ok_or_else(|| bad("profile.deleteImported", "missing id"))?.to_string();
if super::dcp_profiles::is_dcp_id(&id) {
return s.execute("profile.deleteCamera", p);
}
let Some(i) = s.lut_profiles.iter().position(|x| x.id == id) else {
return Err(bad("profile.deleteImported", format!("no imported profile `{id}`")));
};
Expand Down
2 changes: 2 additions & 0 deletions crates/engine/src/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mod color;
pub(crate) mod convert;
mod cull;
pub mod curves;
pub mod dcp_profiles;
pub(crate) mod denoise;
mod develop;
mod edit;
Expand Down Expand Up @@ -151,6 +152,7 @@ pub fn command_specs() -> &'static [CommandSpec] {
v.extend(manage::specs());
v.extend(previews::specs());
v.extend(lut_profiles::specs());
v.extend(dcp_profiles::specs());
v.extend(mask_effects::specs());
v.extend(cull::specs());
v.extend(convert::specs());
Expand Down
14 changes: 12 additions & 2 deletions crates/engine/src/cmd/previews.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@ struct SmartCounts {
fn original_only(source: crate::media::SourceRef) -> Option<crate::media::SourceRef> {
use crate::media::SourceRef;
match source {
SourceRef::File { path, max_edge, loader, denoise, .. } => Some(SourceRef::File { path, max_edge, loader, fallback: None, denoise }),
// (a smart preview keeps the file's own colour: an imported camera profile is applied when the original is read)
SourceRef::File { path, max_edge, loader, denoise, .. } => {
Some(SourceRef::File { path, max_edge, loader, fallback: None, denoise, camera_profile: None })
}
SourceRef::Loaded(d) if d.info.is_some() => Some(SourceRef::Loaded(d)),
_ => None,
}
Expand Down Expand Up @@ -548,7 +551,14 @@ mod tests {
let mut jobs = jobs_for(&mut s, id, Some(512));
assert_eq!(jobs.len(), 2, "view and thumbnail");
assert!(jobs[0].view_cache.is_some(), "the view renders first");
jobs[1].source = SourceRef::File { path: "/nonexistent/photo.arw".into(), max_edge: 512, loader: None, fallback: None, denoise: None };
jobs[1].source = SourceRef::File {
path: "/nonexistent/photo.arw".into(),
max_edge: 512,
loader: None,
fallback: None,
denoise: None,
camera_profile: None,
};
assert!(run_photo(jobs), "the thumbnail rendered from the view's decoded source");
}

Expand Down
Loading