Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

LR-LIB-CULL: adjustable burst gap and similarity in Assisted Culling (#2275)

helgehelge1237f2375458c89
diff --git a/crates/engine/src/cmd/cull.rs b/crates/engine/src/cmd/cull.rs
index 030cb6e93..92a9c3b7c 100644
--- a/crates/engine/src/cmd/cull.rs
+++ b/crates/engine/src/cmd/cull.rs
@@ -9,10 +9,12 @@ use serde_json::{Value, json};
use super::{CommandSpec, always, cmd};
use crate::{Result, Session};
-/// Seconds between shots of the same burst at most.
-const BURST_GAP: i64 = 10;
-/// Signature similarity for "the same scene".
-const SAME: f32 = 0.93;
+/// Seconds between shots of the same burst at most (default of `burstGap`).
+const BURST_GAP: f64 = 10.0;
+/// Signature similarity for "the same scene" (default of `similarity`).
+const SAME: f64 = 0.93;
+/// The longest `burstGap` accepted: a day.
+const MAX_GAP: f64 = 86_400.0;
fn secs(iso: &str) -> Option<i64> {
let d = lightcraft_meta::DateTime::parse_iso(iso)?;
@@ -23,6 +25,7 @@ fn analyze(s: &mut Session, p: &Value) -> Result<Value> {
let ids: Vec<PhotoId> = if p.get("ids").is_some() || s.selection.ids.len() > 1 { s.targets(p)? } else { s.visible_cloned() };
let reject_below = p.get("rejectBelow").and_then(Value::as_f64).map(|v| v as f32);
let pick_best = p.get("pickBest").and_then(Value::as_bool).unwrap_or(false);
+ let (gap, same) = burst_params(p)?;
// measure (thumbnail-level sources: fast, and enough for focus at 512 px)
let mut rows: Vec<(PhotoId, Option<i64>, f32, f32, [f32; 64])> = Vec::new();
let mut failed = Vec::new();
@@ -42,8 +45,8 @@ fn analyze(s: &mut Session, p: &Value) -> Result<Value> {
let mut next = 1u32;
for i in 1..rows.len() {
let (a, b) = (&rows[i - 1], &rows[i]);
- let close = matches!((a.1, b.1), (Some(x), Some(y)) if (y - x).abs() <= BURST_GAP);
- if close && lightcraft_pipeline::cull::similarity(&a.4, &b.4) >= SAME {
+ let close = matches!((a.1, b.1), (Some(x), Some(y)) if (y.saturating_sub(x)).unsigned_abs() as f64 <= gap);
+ if close && lightcraft_pipeline::cull::similarity(&a.4, &b.4) >= same {
let g = *group_of[i - 1].get_or_insert_with(|| {
next += 1;
next - 1
@@ -83,6 +86,22 @@ fn analyze(s: &mut Session, p: &Value) -> Result<Value> {
Ok(json!({"photos": out, "groups": best.len(), "rejected": rejected, "picked": picked, "failed": failed}))
}
+/// `burstGap` (seconds, 0..=a day) and `similarity` (0..=1) of `photo.analyze`, refused before
+/// anything is measured when they are not numbers in range.
+fn burst_params(p: &Value) -> Result<(f64, f32)> {
+ const C: &str = "photo.analyze";
+ let num = |key: &str, d: f64, max: f64| -> Result<f64> {
+ match p.get(key) {
+ None | Some(Value::Null) => Ok(d),
+ Some(v) => match v.as_f64() {
+ Some(x) if x.is_finite() && (0.0..=max).contains(&x) => Ok(x),
+ _ => Err(super::bad(C, format!("`{key}` must be a number from 0 to {max}"))),
+ },
+ }
+ };
+ Ok((num("burstGap", BURST_GAP, MAX_GAP)?, num("similarity", SAME, 1.0)? as f32))
+}
+
/// Find Similar: photos that look like `id` (signatures from thumbnail-level sources, cached by
/// content), most similar first; the view is filtered to them.
fn find_similar(s: &mut Session, p: &Value) -> Result<Value> {
@@ -133,7 +152,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Assisted Culling",
[],
None,
- "{ids?, rejectBelow?: sharpness 0..100, pickBest?: bool} — score the selected photos (else all in view) for focus (0..100) and clipping, group look-alike shots taken within 10 s and mark the sharpest of each; optionally reject blurry photos and pick each group's best; one undo step → {photos: [{id, sharpness, clipped, group, best}], groups, rejected, picked}",
+ "{ids?, rejectBelow?: sharpness 0..100, pickBest?: bool, burstGap?: seconds 0..86400 (10), similarity?: 0..1 (0.93)} — score the selected photos (else all in view) for focus (0..100) and clipping, group look-alike shots (signature similarity at least `similarity`) taken at most `burstGap` seconds apart and mark the sharpest of each; optionally reject blurry photos and pick each group's best; one undo step → {photos: [{id, sharpness, clipped, group, best}], groups, rejected, picked}",
always,
analyze
),
diff --git a/crates/engine/src/tests_import.rs b/crates/engine/src/tests_import.rs
index 13f02ce77..f581f11dd 100644
--- a/crates/engine/src/tests_import.rs
+++ b/crates/engine/src/tests_import.rs
@@ -822,6 +822,54 @@ fn assisted_culling_groups_bursts_across_month_end() {
let _ = std::fs::remove_dir_all(&dir);
}
+/// Assisted culling: `burstGap` and `similarity` move the burst limits (#2275), and values out of
+/// range are refused before anything is measured or stored.
+#[test]
+fn assisted_culling_burst_limits_are_adjustable() {
+ let dir = temp_dir("cull-limits");
+ for (name, (w, h)) in [("a.png", (480, 320)), ("b.png", (482, 321))] {
+ let img = lightcraft_scenes::demo_library()[0].render(w, h);
+ let data: Vec<[u8; 4]> = img
+ .data
+ .iter()
+ .map(|c| {
+ let e = |v: f32| (lightcraft_color::transfer::linear_to_srgb(v.clamp(0.0, 1.0)) * 255.0).round() as u8;
+ [e(c[0]), e(c[1]), e(c[2]), 255]
+ })
+ .collect();
+ let png = lightcraft_codecs::encode_png(
+ &lightcraft_codecs::EncodeImage::rgba8(&lightcraft_raster::Rgba8 { width: img.width, height: img.height, data }),
+ &Default::default(),
+ )
+ .unwrap();
+ std::fs::write(dir.join(name), png).unwrap();
+ }
+ let mut s = Session::new().with_fs();
+ let r = s.execute("library.import", &json!({"paths": [dir.to_string_lossy()]})).unwrap();
+ let ids: Vec<u64> = r["imported"].as_array().unwrap().iter().filter_map(Value::as_u64).collect();
+ let by_name = |s: &Session, n: &str| s.catalog.photos().find(|p| p.file_name == n).unwrap().id;
+ let (a, b) = (by_name(&s, "a.png"), by_name(&s, "b.png"));
+ s.commit("t", lightcraft_catalog::Op::SetCaptured { id: a, captured: Some("2026-05-01T10:00:00".into()) }).unwrap();
+ s.commit("t", lightcraft_catalog::Op::SetCaptured { id: b, captured: Some("2026-05-01T10:00:15".into()) }).unwrap();
+ // 15 s apart: past the default 10 s, inside a 20 s gap
+ assert_eq!(s.execute("photo.analyze", &json!({"ids": ids})).unwrap()["groups"], 0);
+ assert_eq!(s.execute("photo.analyze", &json!({"ids": ids, "burstGap": 20})).unwrap()["groups"], 1);
+ // the look-alike pair is a burst at the default similarity, not when it must be identical
+ let strict = s.execute("photo.analyze", &json!({"ids": ids, "burstGap": 20, "similarity": 1.0})).unwrap();
+ assert_eq!(strict["groups"], 0, "{strict}");
+ // bad values change nothing
+ let undo_before = s.commits();
+ for bad in
+ [json!({"burstGap": -1}), json!({"burstGap": 86401}), json!({"burstGap": "10"}), json!({"similarity": 1.5}), json!({"similarity": -0.1})]
+ {
+ let mut p = bad.clone();
+ p["ids"] = json!(ids);
+ assert!(s.execute("photo.analyze", &p).is_err(), "{bad} must be refused");
+ }
+ assert_eq!(s.commits(), undo_before);
+ let _ = std::fs::remove_dir_all(&dir);
+}
+
/// Find Dust Spots: soft dark spots on a smooth sky are found and healed (one undo step).
#[test]
fn dust_spots_are_found_and_healed() {
diff --git a/crates/ui-egui/locales/de.json b/crates/ui-egui/locales/de.json
index 000aea2d4..9d2d75680 100644
--- a/crates/ui-egui/locales/de.json
+++ b/crates/ui-egui/locales/de.json
@@ -1205,6 +1205,9 @@
"Refresh View": "Ansicht aktualisieren",
"Reject": "Ablehnen",
"Reject below focus": "Unter Schärfegrenzwert ablehnen",
+ "Burst: shots at most this far apart": "Serie: Aufnahmen höchstens so weit auseinander",
+ "Burst: how alike (loose … strict)": "Serie: wie ähnlich (locker … streng)",
+ "Lower it when a panning or moving burst splits into several groups.": "Senken, wenn eine Mitzieher- oder Bewegungsserie in mehrere Gruppen zerfällt.",
"Rejected": "Abgelehnt",
"Rejects": "Abgelehnte Fotos",
"Reliability": "Zuverlässigkeit",
diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs
index 743bd4600..229b34dc6 100644
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@ -1443,7 +1443,8 @@ pub fn run_ui_command(app: &mut LightcraftApp, id: &str, p: &Value) -> Option<Re
"photo.editInExternal" => edit_in(app, &ctx, p, false),
"photo.openOriginalInExternal" => open_original_in(app, &ctx, p),
"dialog.cull" => {
- app.ui.dialog = Some(Dialog::Cull { reject_below: 0.0, pick_best: true });
+ let (burst_gap, similarity) = app.ui.cull_burst.unwrap_or((10.0, 0.93));
+ app.ui.dialog = Some(Dialog::Cull { reject_below: 0.0, pick_best: true, burst_gap, similarity });
Ok(Value::Null)
}
"app.whatsNew" => {
diff --git a/crates/ui-egui/src/panels/dialogs.rs b/crates/ui-egui/src/panels/dialogs.rs
index 5562e94d1..621492ecb 100644
--- a/crates/ui-egui/src/panels/dialogs.rs
+++ b/crates/ui-egui/src/panels/dialogs.rs
@@ -336,7 +336,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {
egui::RichText::new(crate::i18n::tr_format!("Creates {} stacks from {} of {scope}", preview["stacks"], preview["photos"], scope = crate::i18n::tr(scope))).color(t.text_dim),
);
}
- Dialog::Cull { reject_below, pick_best } => {
+ Dialog::Cull { reject_below, pick_best, burst_gap, similarity } => {
let n = app.session.selection.ids.len();
let scope = if n > 1 { crate::i18n::tr_format!("the {n} selected photos", n = n) } else { crate::i18n::tr_format!("the {} photos in view", app.session.visible_cloned().len()) };
ui.label(egui::RichText::new(crate::i18n::tr_format!("Scores {scope} for focus and exposure and finds similar shots taken within seconds of each other (bursts).", scope = scope)).color(t.text_label));
@@ -346,6 +346,18 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {
ui.label(egui::RichText::new(crate::i18n::tr(if *reject_below > 0.0 { "Blurry photos below the score are flagged as rejects." } else { "0: nothing is rejected." })).color(t.text_dim));
let r = ui.checkbox(pick_best, crate::i18n::tr("Pick the sharpest photo of each burst"));
crate::widgets::register(ui.ctx(), "check:cullPick", r.rect);
+ ui.add_space(6.0);
+ let r = ui.add(
+ egui::Slider::new(burst_gap, 1.0..=600.0)
+ .logarithmic(true)
+ .text(crate::i18n::tr("Burst: shots at most this far apart"))
+ .custom_formatter(|v, _| crate::panels::dialogs::fmt_gap(v))
+ .custom_parser(|s| s.trim().trim_end_matches('s').trim().parse().ok()),
+ );
+ crate::widgets::register(ui.ctx(), "field:cullGap", r.rect);
+ let r = ui.add(egui::Slider::new(similarity, 0.70..=0.99).text(crate::i18n::tr("Burst: how alike (loose … strict)")).step_by(0.01).fixed_decimals(2));
+ crate::widgets::register(ui.ctx(), "field:cullSimilar", r.rect);
+ ui.label(egui::RichText::new(crate::i18n::tr("Lower it when a panning or moving burst splits into several groups.")).color(t.text_dim));
ui.label(egui::RichText::new(crate::i18n::tr("Scores stay on the photos: filter or make smart albums with Focus and Best of Similar Shots.")).color(t.text_dim));
}
Dialog::WhatsNew => {
@@ -1870,8 +1882,9 @@ pub fn confirm_dialog(app: &mut LightcraftApp, dlg: &Dialog) -> Result<serde_jso
Dialog::DenoiseModel { info, accepted } => crate::panels::denoise::install(app, info, *accepted),
Dialog::FaceModel { path, info, accepted } => crate::panels::faces::install(app, path, info, *accepted),
Dialog::AllMetadata { .. } | Dialog::SystemInfo { .. } | Dialog::WhatsNew => Ok(serde_json::Value::Null),
- Dialog::Cull { reject_below, pick_best } => {
- let mut p = json!({"pickBest": pick_best});
+ Dialog::Cull { reject_below, pick_best, burst_gap, similarity } => {
+ app.ui.cull_burst = Some((*burst_gap, *similarity));
+ let mut p = json!({"pickBest": pick_best, "burstGap": burst_gap, "similarity": similarity});
if *reject_below > 0.0 {
p["rejectBelow"] = json!(reject_below);
}
diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs
index f8c8cc0d4..3388bad3b 100644
--- a/crates/ui-egui/src/state.rs
+++ b/crates/ui-egui/src/state.rs
@@ -728,6 +728,10 @@ pub struct UiState {
/// The last person page left: the People view offers a way back to it next to its title.
#[serde(skip)]
pub last_person: Option<String>,
+ /// Assisted Culling's burst settings last confirmed (gap in seconds, similarity), for this
+ /// session; `None` until the dialog is first confirmed (then 10 s, 0.93).
+ #[serde(skip)]
+ pub cull_burst: Option<(f32, f32)>,
/// "More" faces the user hid with ×, for this session: (photo, region index).
#[serde(skip)]
pub dismissed_faces: std::collections::HashSet<(u64, usize)>,
@@ -1089,10 +1093,13 @@ pub enum Dialog {
/// Help ▸ What's New.
WhatsNew,
/// Photo ▸ Assisted Culling: reject photos below this focus score (0 = none), pick the best
- /// of each burst.
+ /// of each burst; shots at most `burst_gap` seconds apart and at least `similarity` alike are
+ /// a burst.
Cull {
reject_below: f32,
pick_best: bool,
+ burst_gap: f32,
+ similarity: f32,
},
/// Help ▸ System Info: (label, value) rows.
DenoiseModel {
@@ -1313,6 +1320,7 @@ impl Default for UiState {
person_page: None,
person_from: None,
last_person: None,
+ cull_burst: None,
dismissed_faces: Default::default(),
unnamed_selected: Default::default(),
unnamed_name: String::new(),
diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md
index 4e0531793..9cce61b9a 100644
--- a/docs/parity-checklist.md
+++ b/docs/parity-checklist.md
@@ -1,6 +1,6 @@
# Lightroom parity checklist
-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-15 · **Change:** minor (LRC-PRINT-PAGE: Print Page Options) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6
+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-19 · **Change:** patch (LR-LIB-CULL: adjustable burst limits) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6
The measured, row-by-row checklist: one row per Lightroom feature, menu item and shortcut, what we
have and what is missing. It answers *does the feature exist?* (feature breadth). Whether it is good
@@ -116,7 +116,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts).
| LR-LIB-CAPTURETIME | Edit capture time | P1 | ✅ | `cmd:photo.setCaptureTime`, `cmd:dialog.captureTime`, `crates/catalog/src/dates.rs` | set (the other selected photos shift by the same amount, or `each`), shift by days/hours/minutes, time-zone shift; one undo step, journaled; Info panel button; no “revert to original capture time”. Impossible calendar dates cannot anchor relative shifts; rejection preserves metadata, selection, Undo and Redo. |
| LR-LIB-SHOWFINDER | Reveal original in file manager | P0 | ✅ | `cmd:app.showInFinder` | ⌘R (see MENU-FILE-SHOWFINDER) |
| LR-LIB-COVER | Album cover | P2 | ✅ | `cmd:album.setCover` | |
-| LR-LIB-CULL | Assisted culling | P2 | 🟡 | `cmd:photo.analyze`, `cmd:dialog.cull`, `crates/pipeline/src/cull.rs` | Photo ▸ Assisted Culling…: focus score (0–100), clipping, burst grouping (look-alike shots within 10 s) with the sharpest marked; reject below a focus score, pick each burst's best; classical measures — no eyes-closed / expression detection |
+| LR-LIB-CULL | Assisted culling | P2 | 🟡 | `cmd:photo.analyze`, `cmd:dialog.cull`, `crates/pipeline/src/cull.rs` | Photo ▸ Assisted Culling…: focus score (0–100), clipping, burst grouping (look-alike shots within 10 s, both limits adjustable in the dialog and as `burstGap` / `similarity`, #2275) with the sharpest marked; reject below a focus score, pick each burst's best; classical measures — no eyes-closed / expression detection |
| LR-LIB-ACTIVITY | Comments & likes | OOS | 🚫 | | |
| LR-LIB-QUICKCOLL | Quick collection [Classic] | P2 | ✅ | `cmd:album.toggleTarget`, `cmd:album.clearQuick` | B in the grids |
| LR-LIB-VIRTUALCOPY | Virtual copies [Classic] | P1 | ✅ | `cmd:photo.virtualCopy`, `cmd:photo.delete`, `crates/engine/src/cmd/organize.rs` | “Copy N” badge, stacked with the original, same albums, no XMP writes; deleting a copy dissolves or renumbers the stack (#1493); no “Set Copy as Master” |
@@ -797,6 +797,7 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove
| Date | Change | Summary |
|---|---|---|
+| 2026-10-19 | patch | LR-LIB-CULL: Assisted Culling's burst gap and similarity are adjustable (dialog, `photo.analyze` `burstGap` / `similarity`; #2275). Statuses and feature counts unchanged. |
| 2026-10-14 | patch | LR-EXP-TYPE: opaque 8-bit PNG/TIFF/WebP use RGB; transparent exports retain alpha (#1670). Statuses and feature counts unchanged. |
| 2026-10-15 | minor | LRC-PRINT-PAGE: Page Options (Page Numbers, Page Info, Crop Marks) on Single Image and Contact Sheet pages, in the Print dialog, `print.set` and templates; still 🟡 (no identity plate, watermark, photo info or Cut Guides) |
| 2026-10-15 | minor | LR-IMP-FORMATS: Hasselblad 3FR and FFF show their uncompressed RGB preview (no JPEG in these files) in the grid and loupe until developed, and as the stand-in when a file fails to decode; status unchanged (🟡) |