Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2ec4add
LR-EDIT-OPTICS-PROFILE: lensfun database downloaded on first run, lib…
OneSlips Oct 22, 2026
030e0ed
LR-EDIT-OPTICS-PROFILE: catalog format 10 for the lens source, snapsh…
OneSlips Oct 26, 2026
5554d78
LR-EDIT-OPTICS-PROFILE: review fixes (desktop library session, stale …
OneSlips Oct 26, 2026
b3b792f
LR-EDIT-OPTICS-PROFILE: merge main (file split)
OneSlips Oct 27, 2026
f7ebead
LR-EDIT-OPTICS-PROFILE: merge main
OneSlips Oct 27, 2026
7a77f72
LR-EDIT-OPTICS-PROFILE: review fixes (CodeRabbit, #3073)
OneSlips Oct 27, 2026
326db68
LR-EDIT-OPTICS-PROFILE: an unlistable lens database folder is an erro…
OneSlips Oct 27, 2026
1d4c53a
Merge remote-tracking branch 'origin/main' into pr/lens-database-down…
OneSlips Oct 27, 2026
f267ddb
LR-EDIT-OPTICS-PROFILE: pinned profiles, whole-folder install, shared…
OneSlips Oct 27, 2026
b7da696
LR-EDIT-OPTICS-PROFILE: review fixes (CodeRabbit, #3073)
OneSlips Oct 27, 2026
bab1e9c
LR-EDIT-OPTICS-PROFILE: look up queued photos as soon as a lookup end…
OneSlips Oct 27, 2026
ef2b209
Merge remote-tracking branch 'origin/main' into pr/lens-database-down…
OneSlips Oct 27, 2026
2cd071c
LR-EDIT-OPTICS-PROFILE: the lens database is offered on first launch …
OneSlips Oct 27, 2026
0fd0ff4
LR-EDIT-OPTICS-PROFILE: a lens database download that can't start kee…
OneSlips Oct 27, 2026
6983520
LR-EDIT-OPTICS-PROFILE: merge main (59a5d00c6, the ui-egui split of #…
OneSlips Oct 28, 2026
3f09c85
LR-EDIT-OPTICS-PROFILE: merge main (integration batch 45)
OneSlips Oct 30, 2026
29443e1
LR-EDIT-OPTICS-PROFILE: merge main (#3430 integration round 3, #3390)
OneSlips Oct 31, 2026
bad1b88
LR-EDIT-OPTICS-PROFILE: a replaced original's missing file correction…
OneSlips Oct 31, 2026
77e6578
LR-EDIT-OPTICS-PROFILE: a database profile is part of the render keys…
OneSlips Oct 31, 2026
0a9707e
LR-EDIT-OPTICS-PROFILE: a decode from before a lens profile change ne…
OneSlips Nov 1, 2026
f3f1831
LR-EDIT-OPTICS-PROFILE: the hover preview follows a new lens profile,…
OneSlips Nov 1, 2026
3698966
LR-EDIT-OPTICS-PROFILE: the lens database folder is held by an operat…
OneSlips Nov 1, 2026
172467b
LR-EDIT-OPTICS-PROFILE: a failed swap keeps the only whole lens datab…
OneSlips Nov 1, 2026
36b2442
Merge remote-tracking branch 'origin/main' into pr-3073
FredApps Nov 4, 2026
9439bf2
Merge remote-tracking branch 'origin/main' into pr-3073
FredApps Nov 4, 2026
0bcc313
Merge remote-tracking branch 'origin/main' into pr-3073
FredApps Nov 4, 2026
9423635
LR-EDIT-OPTICS-PROFILE: merge main (#3550 took catalog format 10; Emb…
FredApps Nov 4, 2026
5da455a
LR-EDIT-OPTICS-PROFILE: merge main (#3144: ILCE-7M3 distortion, kept …
FredApps Nov 4, 2026
86092b3
LR-EDIT-OPTICS-PROFILE: merge main (#2676: unknown crop factors stay …
FredApps Nov 4, 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
49 changes: 41 additions & 8 deletions apps/lightcraft-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ fn merge(args: &[String]) -> Result<(), String> {
}
i += 1;
}
let mut s = Session::new().with_fs().with_default_denoise_models().with_system_clock();
let mut s = file_session();
let paths = expand_paths(&files);
let r = s.execute("library.import", &json!({"paths": paths})).map_err(|e| e.to_string())?;
let mut ids: Vec<u64> = r["imported"].as_array().map(|a| a.iter().filter_map(Value::as_u64).collect()).unwrap_or_default();
Expand Down Expand Up @@ -703,6 +703,12 @@ fn read_settings(p: &str) -> Result<SettingsFile, String> {
}
}

/// The session `render` and `merge` develop files in: with the lens database the desktop app downloaded, when it is
/// there (never fetched from here: scripts and tests stay offline).
fn file_session() -> Session {
Session::new().with_fs().with_default_denoise_models().with_system_clock().with_default_lens_database()
}

fn render(args: &[String]) -> Result<(), String> {
let mut input = None;
let mut output = None;
Expand Down Expand Up @@ -741,7 +747,7 @@ fn render(args: &[String]) -> Result<(), String> {
}
let input = input.ok_or("render: missing input file")?;
let output = output.ok_or("render: missing -o OUTPUT")?;
let mut s = Session::new().with_fs().with_default_denoise_models().with_system_clock();
let mut s = file_session();
let abs = expand_paths(std::slice::from_ref(&input));
let r = s.execute("library.import", &json!({"paths": abs})).map_err(|e| e.to_string())?;
let id = r["imported"][0].as_u64().ok_or_else(|| format!("{input}: not a readable photo"))?;
Expand Down Expand Up @@ -836,15 +842,30 @@ fn snapshot(args: &[String]) -> Result<(), String> {
let t0 = Instant::now();
let mut session = match &library {
Some(dir) => {
let mut s =
Session::new().with_fs().with_default_denoise_models().with_system_clock().with_default_face_models().with_default_slide_templates();
let mut s = Session::new()
.with_fs()
.with_default_denoise_models()
.with_system_clock()
.with_default_face_models()
.with_default_lens_database()
.with_default_slide_templates();
s.open_library(dir, false).map_err(|e| library_error(dir, e))?;
s
}
None if files.is_empty() => {
Session::with_demo().with_fs().with_default_denoise_models().with_system_clock().with_default_face_models().with_default_slide_templates()
}
None => Session::new().with_fs().with_default_denoise_models().with_system_clock().with_default_face_models().with_default_slide_templates(),
None if files.is_empty() => Session::with_demo()
.with_fs()
.with_default_denoise_models()
.with_system_clock()
.with_default_face_models()
.with_default_lens_database()
.with_default_slide_templates(),
None => Session::new()
.with_fs()
.with_default_denoise_models()
.with_system_clock()
.with_default_face_models()
.with_default_lens_database()
.with_default_slide_templates(),
};
// Apply compute policy before imports or the first scripted query can discover an adapter.
session.execute("app.gpu", &json!({"enabled": false})).map_err(|e| e.to_string())?;
Expand Down Expand Up @@ -1069,6 +1090,18 @@ fn denoise_serve(_: &[String]) -> Result<(), String> {
Err("denoise-serve: this build has no denoise support (build with the `denoise` feature)".into())
}

#[cfg(test)]
mod tests {
/// `render` and `merge` read the lens database the desktop app downloaded, as the desktop does (the same raw
/// gets the same profile everywhere), but never fetch it.
#[test]
fn render_reads_the_downloaded_lens_database() {
let s = super::file_session();
assert_eq!(lightcraft_engine::lens_profiles::host_dir(), lightcraft_engine::lensfun_download::default_dir());
assert!(!s.lens_auto_download, "selecting it is not permission to download it");
}
}

#[cfg(test)]
mod import_target_tests {
use super::{import_and_select, import_targets, json};
Expand Down
4 changes: 4 additions & 0 deletions apps/lightcraft/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ pub(crate) fn open_session(in_memory: bool, launch: &Launch, seed_demo: bool) ->
Launch::Ask => (Session::new().with_fs().with_default_denoise_models().with_system_clock(), None),
Launch::Open { dir, remembered, .. } => open_library_session(in_memory, dir.clone(), *remembered, seed_demo),
};
// lens profiles from the app's own lensfun copy, offered on the first launch (not for a throwaway session)
if !in_memory {
s = s.with_default_lens_database().with_lens_auto_download();
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
s.face_models_dir = lightcraft_engine::config::default_face_models_dir();
s.slide_templates_dir = lightcraft_engine::config::config_dir().map(|d| d.join(lightcraft_engine::slide_template::DIR_NAME));
// Control requests are answered on the UI thread: Add to Apple Photos must not wait there
Expand Down
3 changes: 2 additions & 1 deletion crates/catalog/src/journal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
//! | 7 | Kelvin white balance for raws whose camera has matrices (#730) | `Op::SetAsShotWb`, `WhiteBalance.scale` |
//! | 8 | History cursor: Go to History Step adds no step | `Op::SetHistoryCursor`, `Photo.history_cursor` |
//! | 9 | preview-only recheck | `Photo.preview_checked`, `Op::SetContent.preview_checked` |
//! | 10 | lens database profiles named in the Optics panel | `EmbeddedLens.source` |
//!
//! Rules:
//! - **Bump [`VERSION`]** (and add a row above) in the change that adds an [`Op`] variant or a
Expand All @@ -76,7 +77,7 @@ pub const LOG: &str = "catalog.log";
const FORMAT: &str = "lightcraft-catalog";
/// The catalog format this build writes (and the newest it reads). See the module docs →
/// *Format versions*; bump it whenever an [`Op`] variant or a serialized field is added.
pub const VERSION: u32 = 9;
pub const VERSION: u32 = 10;

/// When [`Journal::wants_snapshot`] says it's time to compact the log.
#[derive(Clone, Copy, Debug)]
Expand Down
3 changes: 2 additions & 1 deletion crates/catalog/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,8 @@ fn set_embedded_lens_is_undoable_and_journaled() {
photo: Box::new(Photo::new(a, Source::File { path: "/x.rw2".into() }, "x.rw2", "RW2", 4000, 3000, "2026-10-06T00:00:00")),
})
.unwrap();
let lens = lightcraft_develop::EmbeddedLens { warp: Some(Default::default()), vignette: None, stages: Default::default() };
let lens =
lightcraft_develop::EmbeddedLens { warp: Some(Default::default()), vignette: None, stages: Default::default(), source: Default::default() };
let op = Op::SetEmbeddedLens { id: a, lens: Some(Box::new(lens)) };
let op: Op = serde_json::from_str(&serde_json::to_string(&op).unwrap()).unwrap();
let inv = c.apply(op).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions crates/catalog/src/tests_format_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ fn op_variants_are_versioned() {
Op::SetHistoryCursor { .. } => 8,
}
}
/// v9: `Photo.preview_checked` and `Op::SetContent.preview_checked`.
const NEWEST_FIELDS: u32 = 9;
/// v9: `Photo.preview_checked` and `Op::SetContent.preview_checked`; v10: `EmbeddedLens.source`.
const NEWEST_FIELDS: u32 = 10;
let newest = since(&Op::SetHistoryCursor { id: PhotoId(1), cursor: None });
assert_eq!(newest.max(NEWEST_FIELDS), VERSION, "the newest op's or fields' version must be the current format version");
}
21 changes: 21 additions & 0 deletions crates/develop/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,11 +699,32 @@ impl Default for Optics {
pub struct EmbeddedLens {
pub warp: Option<EmbeddedWarp>,
pub vignette: Option<EmbeddedVignette>,
/// Where the correction came from: the file itself, or a lens database looked up by the
/// lens named in the file (what the Optics panel says is loaded).
#[serde(skip_serializing_if = "LensSource::is_file")]
pub source: LensSource,
/// A DNG 1.6 `WarpRectilinear2` chain (up to [`WARP_STAGES`] stages, in `OpcodeList3` order; each stage warps
/// the result of the one before it). When any is set, `warp` is `None`: the chain holds every warp opcode.
pub stages: [Option<EmbeddedWarpStage>; WARP_STAGES],
}

/// Where an [`EmbeddedLens`] came from.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum LensSource {
/// The file's own correction (DNG opcodes, a camera's correction a raw reader converts).
#[default]
File,
/// A profile from a lensfun-format lens database, matched by the lens named in the file.
Database,
}

impl LensSource {
pub fn is_file(&self) -> bool {
*self == LensSource::File
}
}

/// Most warp stages an [`EmbeddedLens`] chain keeps.
pub const WARP_STAGES: usize = 3;

Expand Down
2 changes: 2 additions & 0 deletions crates/engine/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub mod filters;
mod focus;
pub mod geocode;
pub mod keywords;
pub mod lens_refresh;
pub mod library;
pub mod lut_profiles;
pub mod manage;
Expand Down Expand Up @@ -168,6 +169,7 @@ pub fn command_specs() -> &'static [CommandSpec] {
v.extend(browse::specs());
v.extend(missing::specs());
v.extend(recheck::specs());
v.extend(lens_refresh::specs());
v.extend(sync::specs());
v.extend(metadata::specs());
v.extend(geocode::specs());
Expand Down
1 change: 1 addition & 0 deletions crates/engine/src/cmd/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ mod tests {
warp: Some(lightcraft_develop::EmbeddedWarp { planes: [[1.0, -0.1, 0.03, 0.0, 0.0, 0.0]; 3], ..Default::default() }),
vignette: None,
stages: Default::default(),
source: Default::default(),
}
}
fn old_rw2() -> lightcraft_catalog::Photo {
Expand Down
Loading
Loading