diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2009-11-26 09:38:43 +0100 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2009-11-26 09:38:43 +0100 |
commit | cd41bb7689f249d8274db8aff0d9b8b65ca860e3 (patch) | |
tree | 5f9b0dad7c36655ba769e95f7cad2f998465e97c | |
parent | 807a521612225de719d5461cbeac5a7fd145a520 (diff) | |
download | pyexiv2-cd41bb7689f249d8274db8aff0d9b8b65ca860e3.tar.gz |
Use the (much more reliable) exiv2 type of the XMP tag to get its correct value.
-rw-r--r-- | src/exiv2wrapper.cpp | 7 | ||||
-rw-r--r-- | src/exiv2wrapper.hpp | 2 | ||||
-rw-r--r-- | src/exiv2wrapper_python.cpp | 1 | ||||
-rw-r--r-- | src/pyexiv2/xmp.py | 9 |
4 files changed, 15 insertions, 4 deletions
diff --git a/src/exiv2wrapper.cpp b/src/exiv2wrapper.cpp index 1b9dd8d..7455477 100644 --- a/src/exiv2wrapper.cpp +++ b/src/exiv2wrapper.cpp @@ -634,6 +634,8 @@ XmpTag::XmpTag(const std::string& key, Exiv2::Xmpdatum* datum): _key(key) _datum = new Exiv2::Xmpdatum(_key); } + _exiv2_type = _datum->typeName(); + const char* title = Exiv2::XmpProperties::propertyTitle(_key); if (title != 0) { @@ -664,6 +666,11 @@ const std::string XmpTag::getKey() return _key.key(); } +const std::string XmpTag::getExiv2Type() +{ + return _exiv2_type; +} + const std::string XmpTag::getType() { return _type; diff --git a/src/exiv2wrapper.hpp b/src/exiv2wrapper.hpp index 90e912f..418fac7 100644 --- a/src/exiv2wrapper.hpp +++ b/src/exiv2wrapper.hpp @@ -111,6 +111,7 @@ public: //void setRawValue(const std::string& value); const std::string getKey(); + const std::string getExiv2Type(); const std::string getType(); const std::string getName(); const std::string getTitle(); @@ -122,6 +123,7 @@ public: private: Exiv2::XmpKey _key; Exiv2::Xmpdatum* _datum; + std::string _exiv2_type; std::string _type; std::string _name; std::string _title; diff --git a/src/exiv2wrapper_python.cpp b/src/exiv2wrapper_python.cpp index cb8907c..e63e651 100644 --- a/src/exiv2wrapper_python.cpp +++ b/src/exiv2wrapper_python.cpp @@ -82,6 +82,7 @@ BOOST_PYTHON_MODULE(libexiv2python) //.def("_setRawValue", &XmpTag::setRawValue) .def("_getKey", &XmpTag::getKey) + .def("_getExiv2Type", &XmpTag::getExiv2Type) .def("_getType", &XmpTag::getType) .def("_getName", &XmpTag::getName) .def("_getTitle", &XmpTag::getTitle) diff --git a/src/pyexiv2/xmp.py b/src/pyexiv2/xmp.py index bc28109..c66a754 100644 --- a/src/pyexiv2/xmp.py +++ b/src/pyexiv2/xmp.py @@ -85,12 +85,13 @@ class XmpTag(object): def _from_existing_tag(_tag): # Build a tag from an already existing _XmpTag tag = XmpTag(_tag._getKey(), _tag=_tag) - if tag.type[:4] in ('seq ', 'bag ', 'alt '): + type = _tag._getExiv2Type() + if type == 'XmpText': + tag.raw_value = _tag._getTextValue() + elif type in ('XmpAlt', 'XmpBag', 'XmpSeq'): tag.raw_value = _tag._getArrayValue() - elif tag.type == 'Lang Alt': + elif type == 'LangAlt': tag.raw_value = _tag._getLangAltValue() - else: - tag.raw_value = _tag._getTextValue() return tag @property |