summary history branches tags files
commit:fca8c9f3cf33990b050ce6502df263d66f51849c
author:Trevor Bentley
committer:Trevor Bentley
date:Mon Jan 13 22:13:39 2025 +0100
parents:33f0544953164fe80ec915e8c96bf9ecb7ac87b7
add pww processed metadata tag
diff --git a/README.md b/README.md
line changes: +7/-0
index 988ce3d..a84f964
--- a/README.md
+++ b/README.md
@@ -213,6 +213,13 @@ permitted_tags = []
 # Only exact matches are supported.
 #
 forbidden_tags = []
+
+# Disables setting of the pww processed metadata field.
+#
+# pww sets an Xmp tag indicating it has processed a file.  This can be used to
+# skip reprocessing of files that have already been handled.
+#
+disable_pww_tag = false
 ```
 
 ## Command-line arguments

diff --git a/src/main.rs b/src/main.rs
line changes: +23/-0
index 8d3081f..20a8dda
--- a/src/main.rs
+++ b/src/main.rs
@@ -75,6 +75,10 @@ struct PwwArgs {
     #[arg(long)]
     keep_converted: bool,
 
+    /// Disables setting of the pww processed metadata field.
+    #[arg(long)]
+    disable_pww_tag: bool,
+
     /// Image files to analyze and tag
     #[arg(trailing_var_arg = true, allow_hyphen_values = true, value_name = "IMAGE", required = true)]
     image_paths: Vec<PathBuf>,
@@ -249,6 +253,13 @@ struct PwwConfig {
     /// metadata.
     forbidden_tags: Vec<String>,
 
+    /// Disables setting of the pww processed metadata field.
+    ///
+    /// pww sets an Xmp tag indicating it has processed a file.  This
+    /// can be used to skip reprocessing of files that have already
+    /// been handled.
+    disable_pww_tag: bool,
+
     #[serde(skip_serializing, skip_deserializing)]
     cli: Option<PwwArgs>,
 }
@@ -309,6 +320,10 @@ impl PwwConfig {
     fn keep_converted(&self) -> bool {
         self.cli.as_ref().map(|c| c.keep_converted).unwrap_or_default()
     }
+
+    fn disable_pww_tag(&self) -> bool {
+        self.cli.as_ref().map(|c| c.disable_pww_tag).unwrap_or_default()
+    }
 }
 
 impl ::std::default::Default for PwwConfig {
@@ -344,6 +359,7 @@ impl ::std::default::Default for PwwConfig {
                                      ValidImageColor::Rgba16
             ),
             halt_on_error: false,
+            disable_pww_tag: false,
             permitted_tags: vec!(),
             forbidden_tags: vec!(),
             cli: None,
@@ -591,6 +607,13 @@ 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)
+            .map_err(|_e| PwwError::Unknown("Couldn't set pww processed tag".into()))?;
+    }
+
     match config.dry_run() {
         false => {
             meta.save_to_file(&filepath)