From e750bcdb8c88729efa9e68686e4cdbbc15a010e4 Mon Sep 17 00:00:00 2001 From: Duncan Tourolle Date: Sat, 19 Sep 2026 22:36:09 +0200 Subject: [PATCH] Date the composite at the mean of its frames' capture times It carried the first frame's, so it sorted before the sweep it was made from. The middle of the sweep puts it among them. --- ui/dr-ui/src/merge.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ui/dr-ui/src/merge.rs b/ui/dr-ui/src/merge.rs index 0dd713a..370d5a8 100644 --- a/ui/dr-ui/src/merge.rs +++ b/ui/dr-ui/src/merge.rs @@ -518,7 +518,16 @@ fn run_inner( let black = first.raw.black_level[0]; let white_level = u32::from(first.raw.white_level.saturating_sub(black)).max(1); let profile = dng_profile(first, white_level); - let (_, carried) = crate::export::header_for_file(&first.meta); + let (_, mut carried) = crate::export::header_for_file(&first.meta); + // The composite is dated at the middle of its sweep — the mean of the + // frames' capture times — so it sorts among the frames it was made + // from, not at the first of them and not at the moment of the merge. + // The zone is the first frame's; a sweep does not cross one. + let stamps: Vec = frames.iter().filter_map(|f| f.meta.captured_at).collect(); + if !stamps.is_empty() { + let sum: i128 = stamps.iter().map(|&t| t as i128).sum(); + carried.captured_at = Some((sum / stamps.len() as i128) as i64); + } let output = MergeOutput { projection,