summary history branches tags files
commit:79ed255f52f5d3d59296d72e494fb0039419f92f
author:Trevor Bentley
committer:Trevor Bentley
date:Mon Jan 13 23:28:39 2025 +0100
parents:58c44473087c14896994cba32d6d972c5818f947
skip tagged files before image conversion
diff --git a/src/main.rs b/src/main.rs
line changes: +28/-23
index bfd31a8..2878398
--- a/src/main.rs
+++ b/src/main.rs
@@ -620,10 +620,14 @@ fn write_tags_to_file<P: AsRef<std::ffi::OsStr>>(config: &PwwConfig, metatags: &
     }
 
     if !config.disable_pww_tag() {
-        let _ = rexiv2::register_xmp_namespace("pww", "photo-what-what");
-        meta.clear_tag("Xmp.photo-what-what.processed");
-        meta.set_tag_numeric("Xmp.photo-what-what.processed", 1)
+        let _ = rexiv2::register_xmp_namespace("http://trevor.town/pww/1.0/", "photo-what-what");
+        let pww_tag = "Xmp.photo-what-what.processed"
+        meta.clear_tag(pww_tag);
+        meta.set_tag_numeric(pww_tag, 1)
             .map_err(|_e| PwwError::Unknown("Couldn't set pww processed tag".into()))?;
+        if config.verbose() {
+            println!(" - set pww processed flag");
+        }
     }
 
     match config.dry_run() {
@@ -654,6 +658,27 @@ fn process_image(config: &PwwConfig, input_path: &Path) -> Result<(), PwwError> 
         println!("Analyzing: {}", analyze_path.to_string_lossy());
     }
 
+    // Check sidecar file before analysis because it's a common error
+    // and we might as well not waste time analyzing when the tags
+    // won't be writeable.
+    let metafile = match should_update_sidecar(&config, &input_path)? {
+        Some(p) => p,
+        None => input_path.to_owned(),
+    };
+
+    // Check the metadata to see if this file has already been
+    // processed, and skip it if configured to do so.
+    let _ = rexiv2::register_xmp_namespace("http://trevor.town/pww/1.0/", "photo-what-what");
+    let meta = rexiv2::Metadata::new_from_path(&metafile)
+        .map_err(|e| PwwError::Unknown(format!("Unable to read metadata from image file: {}", e)))?;
+    let pww_tag = "Xmp.photo-what-what.processed"
+    if config.skip_processed() && meta.get_tag_numeric(pww_tag) == 1 {
+        if config.verbose() {
+            println!(" - already processed, skipped!")
+        }
+        return Ok(());
+    }
+
     // Transcode to a temporary file if necessary
     match image_needs_conversion(&config, &input_path) {
         Ok(true) => {
@@ -712,26 +737,6 @@ fn process_image(config: &PwwConfig, input_path: &Path) -> Result<(), PwwError> 
         _ => {},
     }
 
-    // Check sidecar file before analysis because it's a common error
-    // and we might as well not waste time analyzing when the tags
-    // won't be writeable.
-    let metafile = match should_update_sidecar(&config, &input_path)? {
-        Some(p) => p,
-        None => input_path.to_owned(),
-    };
-
-    // Check the metadata to see if this file has already been
-    // processed, and skip it if configured to do so.
-    let _ = rexiv2::register_xmp_namespace("pww", "photo-what-what");
-    let meta = rexiv2::Metadata::new_from_path(&metafile)
-        .map_err(|e| PwwError::Unknown(format!("Unable to read metadata from image file: {}", e)))?;
-    if config.skip_processed() && meta.get_tag_numeric("Xmp.photo-what-what.processed") == 1 {
-        if config.verbose() {
-            println!(" - already processed, skipped!")
-        }
-        return Ok(());
-    }
-
     // run ML engine on file
     if config.debug() {
         if analyze_path != input_path {