aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2007-09-16 18:48:36 +0200
committerOlivier Tilloy <olivier@tilloy.net>2007-09-16 18:48:36 +0200
commitd79143ade7fab1ce8a07c9a8a09cf9a58a4f8b08 (patch)
tree42f7cc52904f8d0b4c583a2426b6c1ee27de5ca8
parentbee06f46ec991819ee25d86f5cee70209e4f8279 (diff)
downloadpyexiv2-d79143ade7fab1ce8a07c9a8a09cf9a58a4f8b08.tar.gz
When setting a datetime or time tag value, truncate the unused information (microseconds).
-rw-r--r--src/pyexiv2.py16
-rw-r--r--todo1
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;
diff --git a/todo b/todo
index 4a791a9..31613f7 100644
--- a/todo
+++ b/todo
@@ -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