aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/exiv2wrapper.cpp37
-rw-r--r--src/exiv2wrapper.hpp9
-rw-r--r--src/exiv2wrapper_python.cpp1
-rw-r--r--src/pyexiv2.py32
4 files changed, 76 insertions, 3 deletions
diff --git a/src/exiv2wrapper.cpp b/src/exiv2wrapper.cpp
index 5b1f47e..9a423c0 100644
--- a/src/exiv2wrapper.cpp
+++ b/src/exiv2wrapper.cpp
@@ -345,6 +345,43 @@ boost::python::list Image::xmpKeys()
}
}
+boost::python::tuple Image::getXmpTag(std::string key)
+{
+ if(_dataRead)
+ {
+ Exiv2::XmpKey xmpKey = Exiv2::XmpKey(key);
+ boost::python::list values;
+ unsigned int occurences = 0;
+ std::string sTagType;
+ for (Exiv2::XmpMetadata::iterator i = _xmpData.begin();
+ i != _xmpData.end();
+ ++i)
+ {
+ if (i->key() == key)
+ {
+ values.append(i->toString());
+ ++occurences;
+ sTagType = i->typeName();
+ }
+ }
+ if (occurences > 0)
+ {
+ std::string sTagName = xmpKey.tagName();
+ std::string sTagLabel = xmpKey.tagLabel();
+ std::string sTagDesc(Exiv2::XmpProperties::propertyDesc(xmpKey));
+ return boost::python::make_tuple(key, sTagName, sTagLabel, sTagDesc, sTagType, values);
+ }
+ else
+ {
+ throw Exiv2::Error(KEY_NOT_FOUND, key);
+ }
+ }
+ else
+ {
+ throw Exiv2::Error(METADATA_NOT_READ);
+ }
+}
+
/*boost::python::tuple Image::tagDetails(std::string key)
{
std::string keyFamily = key.substr(0, 4);
diff --git a/src/exiv2wrapper.hpp b/src/exiv2wrapper.hpp
index 9d86f1b..f26f9be 100644
--- a/src/exiv2wrapper.hpp
+++ b/src/exiv2wrapper.hpp
@@ -101,7 +101,6 @@ public:
// tagdesc
// type
// tagvalue (list)
- // tagvalue (human-readable) (list)
boost::python::tuple getIptcTag(std::string key);
// Set the IPTC tag's value and return a tuple containing the
@@ -124,6 +123,14 @@ public:
boost::python::list xmpKeys();
+ // key
+ // tagname
+ // taglabel
+ // tagdesc
+ // type
+ // tagvalue (list)
+ boost::python::tuple getXmpTag(std::string key);
+
// Return a tuple containing the name of the tag and its description.
//boost::python::tuple tagDetails(std::string key);
diff --git a/src/exiv2wrapper_python.cpp b/src/exiv2wrapper_python.cpp
index 55c0cf6..4c171bd 100644
--- a/src/exiv2wrapper_python.cpp
+++ b/src/exiv2wrapper_python.cpp
@@ -65,6 +65,7 @@ BOOST_PYTHON_MODULE(libexiv2python)
// .def("_Image__deleteIptcTag", &Image::deleteIptcTag)
.def("xmpKeys", &Image::xmpKeys)
+ .def("_Image__getXmpTag", &Image::getXmpTag)
// .def("tagDetails", &Image::tagDetails)
diff --git a/src/pyexiv2.py b/src/pyexiv2.py
index 801711e..a013c1f 100644
--- a/src/pyexiv2.py
+++ b/src/pyexiv2.py
@@ -416,7 +416,7 @@ class ExifTag(MetadataTag):
def __str__(self):
"""
- Return a string representation of the metadata tag.
+ Return a string representation of the EXIF tag.
"""
r = MetadataTag.__str__(self)
r += os.linesep + 'Formatted value = ' + self.fvalue
@@ -454,7 +454,35 @@ class IptcTag(MetadataTag):
def __str__(self):
"""
- Return a string representation of the metadata tag.
+ Return a string representation of the IPTC tag.
+ """
+ r = MetadataTag.__str__(self)
+ return r.replace('Raw value = ', 'Raw values = ')
+
+
+class XmpTag(MetadataTag):
+
+ """
+ An XMP metadata tag can have several values.
+ """
+
+ def __init__(self, key, name, label, description, type, values):
+ """
+ Constructor.
+ """
+ MetadataTag.__init__(self, key, name, label, description, type, values)
+ self.__convert_values_to_python_type()
+
+ def __convert_values_to_python_type(self):
+ """
+ Convert the stored values from strings to the matching Python type.
+ """
+ # TODO!
+ pass
+
+ def __str__(self):
+ """
+ Return a string representation of the XMP tag.
"""
r = MetadataTag.__str__(self)
return r.replace('Raw value = ', 'Raw values = ')