diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2009-11-16 09:50:33 +0100 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2009-11-16 09:50:33 +0100 |
commit | 918e3ee879d0409c291845968ab0ea54f1b006ee (patch) | |
tree | a11d4b950a530b24731a42ce55601bba55693054 | |
parent | b4d04cb5bf194fb41258340e10a1467abaeb2e13 (diff) | |
download | pyexiv2-918e3ee879d0409c291845968ab0ea54f1b006ee.tar.gz |
Fix setting the value of an EXIF tag.
-rw-r--r-- | src/exiv2wrapper.cpp | 18 | ||||
-rw-r--r-- | src/exiv2wrapper.hpp | 4 | ||||
-rw-r--r-- | src/pyexiv2/exif.py | 5 |
3 files changed, 8 insertions, 19 deletions
diff --git a/src/exiv2wrapper.cpp b/src/exiv2wrapper.cpp index 792b72c..148d367 100644 --- a/src/exiv2wrapper.cpp +++ b/src/exiv2wrapper.cpp @@ -113,22 +113,12 @@ const ExifTag Image::getExifTag(std::string key) void Image::setExifTagValue(std::string key, std::string value) { - if(_dataRead) + if (!_dataRead) { - Exiv2::ExifKey exifKey = Exiv2::ExifKey(key); - Exiv2::ExifMetadata::iterator i = _exifData.findKey(exifKey); - if(i != _exifData.end()) - { - // First erase the existing tag: in some case (and I don't know - // why), the new value won't replace the old one if not previously - // erased... - // TODO: check if this is still valid with libexiv2 0.18 - _exifData.erase(i); - } - _exifData[key] = value; - } - else throw Exiv2::Error(METADATA_NOT_READ); + } + + _exifData[key] = value; } void Image::deleteExifTag(std::string key) diff --git a/src/exiv2wrapper.hpp b/src/exiv2wrapper.hpp index 5dfc1bd..3a216d0 100644 --- a/src/exiv2wrapper.hpp +++ b/src/exiv2wrapper.hpp @@ -127,8 +127,8 @@ public: // Throw an exception if the tag is not set. const ExifTag getExifTag(std::string key); - // Set the EXIF tag's value. If the tag was not previously set, it is - // created. + // Set the EXIF tag's value. + // If the tag was not previously set, it is created. void setExifTagValue(std::string key, std::string value); // Delete the required EXIF tag. diff --git a/src/pyexiv2/exif.py b/src/pyexiv2/exif.py index b6aae32..118321e 100644 --- a/src/pyexiv2/exif.py +++ b/src/pyexiv2/exif.py @@ -77,11 +77,10 @@ class ExifTag(ListenerInterface): else: self._tag = libexiv2python._ExifTag(key) self.metadata = None + self._raw_value = None + self._value = None if value is not None: self._set_value(value) - else: - self._raw_value = None - self._value = None @staticmethod def _from_existing_tag(_tag): |