Added functionality to be able to add Xmp and Iptc tags to plugin images.

svn: r17472
This commit is contained in:
Rob G. Healey 2011-05-11 06:33:25 +00:00
parent 849a3749f6
commit 3e4941632b

View File

@ -921,16 +921,38 @@ class EditExifMetadata(Gramplet):
self.plugin_image[KeyTag] = KeyValue self.plugin_image[KeyTag] = KeyValue
else: else:
try: # tag is being modified... if "Exif" in KeyTag:
self.plugin_image[KeyTag] = KeyValue try: # tag is being modified...
self.plugin_image[KeyTag].value = KeyValue
except KeyError: # tag has not been set... except KeyError: # tag is being created...
self.plugin_image[KeyTag] = pyexiv2.ExifTag(KeyTag, KeyValue) self.plugin_image[KeyTag] = pyexiv2.ExifTag(KeyTag, KeyValue)
except (ValueError, AttributeError): # there is an issue with either KeyTag or KeyValue except (ValueError, AttributeError): # there is an error
pass # 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. writes the Exif metadata to the image.
@ -938,10 +960,10 @@ class EditExifMetadata(Gramplet):
-- pyexiv2-0.2.0 and above... -- pyexiv2-0.2.0 and above...
""" """
if LesserVersion: if LesserVersion:
imageinstance.writeMetadata() plugininstance.writeMetadata()
else: else:
imageinstance.write() plugininstance.write()
# ------------------------------------------------------------------- # -------------------------------------------------------------------
# GPS Coordinates functions # GPS Coordinates functions