Date a photograph from its name when its header has none
WhatsApp strips every EXIF tag and names the file "WhatsApp Image 2023-06-15 at 07.00.42.jpeg"; Windows Phone, Android cameras and darktable's import put the date in the name too. Those images sorted after everything else and were absent from the timeline. name_dates reads a date (and a time, when one follows) from the file name, then from the innermost folder that states one. A sequence number after a date is not read as a time, and a bare year folder is not a date. EXIF always wins: only examined rows still undated are filled. The sweep and the metadata repair fill as they mark an image examined, and the open backfill fills catalogs examined by earlier builds. On the reference library that takes 274 undated images to 10; the no-op case is a seek on images_captured, 0.6 ms an open.
This commit is contained in:
@@ -522,11 +522,16 @@ pub(super) fn flush_sweep(catalog: &Catalog, found: &mut Vec<MetadataFound>) {
|
||||
.filter(|m| m.captured_at.is_none())
|
||||
.map(|m| m.image_id)
|
||||
.collect();
|
||||
for id in ids {
|
||||
for &id in &ids {
|
||||
let _ = catalog
|
||||
.connection()
|
||||
.execute("UPDATE images SET metadata_state = 2 WHERE id = ?1", [id]);
|
||||
}
|
||||
// A header with no date is not a photograph with no date: WhatsApp and
|
||||
// most re-exports strip EXIF and keep the date in the name.
|
||||
if let Err(e) = dr_catalog::name_dates::fill(catalog.connection(), Some(&ids)) {
|
||||
log::warn!("sweep: dating from names: {e}");
|
||||
}
|
||||
found.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -740,6 +740,9 @@ fn metadata(
|
||||
[target.image.0 as i64],
|
||||
)
|
||||
.map_err(|e| Failure::Other(e.to_string()))?;
|
||||
// The name, when the header had no date — as the sweep does.
|
||||
dr_catalog::name_dates::fill(catalog.connection(), Some(&[target.image.0 as i64]))
|
||||
.map_err(|e| Failure::Other(e.to_string()))?;
|
||||
}
|
||||
Ok(1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user