From 3e4941632b69d3c0c6d653a0789fe26b5b4f464c Mon Sep 17 00:00:00 2001 From: "Rob G. Healey" Date: Wed, 11 May 2011 06:33:25 +0000 Subject: [PATCH] Added functionality to be able to add Xmp and Iptc tags to plugin images. svn: r17472 --- src/plugins/gramplet/EditExifMetadata.py | 40 ++++++++++++++++++------ 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/src/plugins/gramplet/EditExifMetadata.py b/src/plugins/gramplet/EditExifMetadata.py index 7c3e04fe4..5861e1643 100644 --- a/src/plugins/gramplet/EditExifMetadata.py +++ b/src/plugins/gramplet/EditExifMetadata.py @@ -921,16 +921,38 @@ class EditExifMetadata(Gramplet): self.plugin_image[KeyTag] = KeyValue else: - try: # tag is being modified... - self.plugin_image[KeyTag] = KeyValue + if "Exif" in KeyTag: + try: # tag is being modified... + self.plugin_image[KeyTag].value = KeyValue - except KeyError: # tag has not been set... - self.plugin_image[KeyTag] = pyexiv2.ExifTag(KeyTag, KeyValue) + except KeyError: # tag is being created... + self.plugin_image[KeyTag] = pyexiv2.ExifTag(KeyTag, KeyValue) - except (ValueError, AttributeError): # there is an issue with either KeyTag or KeyValue - pass + except (ValueError, AttributeError): # there is an error + # with either KeyTag or KeyValue + pass - def write_metadata(self, imageinstance): + elif "Xmp" in KeyTag: + try: + self.plugin_image[KeyTag].value = KeyValue + + except KeyError: + self.plugin_image[KeyTag] = pyexiv2.XmpTag(KeyTag, KeyValue) + + except (ValueError, AttributeError): + pass + + else: + try: + self.plugin_image[KeyTag].value = KeyValue + + except KeyError: + self.plugin_image[KeyTag] = pyexiv2.IptcTag(KeyTag, KeyValue) + + except (ValueError, AttributeError): + pass + + def write_metadata(self, plugininstance): """ writes the Exif metadata to the image. @@ -938,10 +960,10 @@ class EditExifMetadata(Gramplet): -- pyexiv2-0.2.0 and above... """ if LesserVersion: - imageinstance.writeMetadata() + plugininstance.writeMetadata() else: - imageinstance.write() + plugininstance.write() # ------------------------------------------------------------------- # GPS Coordinates functions