diff options
-rw-r--r-- | src/pyexiv2.py | 16 | ||||
-rw-r--r-- | todo | 1 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/pyexiv2.py b/src/pyexiv2.py index 9254d03..a23bfd9 100644 --- a/src/pyexiv2.py +++ b/src/pyexiv2.py @@ -519,6 +519,11 @@ class Image(libpyexiv2.Image): tagFamily = key[:4] if tagFamily == 'Exif': if value is not None: + # For datetime objects, microseconds are not supported by the + # EXIF specification, so truncate them if present. + if value.__class__ is datetime.datetime: + value = value.replace(microsecond=0) + self.__setExifTagValue(key, value) self.__exifTagsDict[key] = value else: @@ -549,6 +554,17 @@ class Image(libpyexiv2.Image): except KeyError: # The tag is not set yet oldValues = () + + # For time objects, microseconds are not supported by the IPTC + # specification, so truncate them if present. + tempNewValues = [] + for newValue in newValues: + if newValue.__class__ is datetime.time: + tempNewValues.append(newValue.replace(microsecond=0)) + else: + tempNewValues.append(newValue) + newValues = tuple(tempNewValues) + # This loop processes the values one by one. There are n cases: # * if the two tuples are of the exact same size, each item in # oldValues is replaced by its new value in newValues; @@ -1,6 +1,5 @@ todo list -- When setting a datetime tag value, truncate the useless information (microseconds) - Add a 'doc' builder to the SConstruct to build the module's documentation - Rewrite the exiv2 command-line tool and the test binaries in Python and (Python) scripts to run the same tests that are run to test exiv2 - Write a complete documentation for the binding and it uses |