diff options
-rw-r--r-- | src/libpyexiv2.cpp | 24 | ||||
-rw-r--r-- | src/libpyexiv2.hpp | 6 | ||||
-rw-r--r-- | src/libpyexiv2_wrapper.cpp | 2 |
3 files changed, 32 insertions, 0 deletions
diff --git a/src/libpyexiv2.cpp b/src/libpyexiv2.cpp index f77b6c7..6eebbdd 100644 --- a/src/libpyexiv2.cpp +++ b/src/libpyexiv2.cpp @@ -88,6 +88,18 @@ namespace LibPyExiv2 throw Exiv2::Error(METADATA_NOT_READ); } + bool Image::isExifTagSet(std::string key) + { + if(_dataRead) + { + Exiv2::ExifKey exifKey = Exiv2::ExifKey(key); + Exiv2::ExifMetadata::iterator i = _exifData.findKey(exifKey); + return (i != _exifData.end()); + } + else + throw Exiv2::Error(METADATA_NOT_READ); + } + boost::python::tuple Image::getExifTag(std::string key) { if(_dataRead) @@ -192,6 +204,18 @@ namespace LibPyExiv2 throw Exiv2::Error(METADATA_NOT_READ); } + bool Image::isIptcTagSet(std::string key) + { + if(_dataRead) + { + Exiv2::IptcKey iptcKey = Exiv2::IptcKey(key); + Exiv2::IptcMetadata::iterator i = _iptcData.findKey(iptcKey); + return (i != _iptcData.end()); + } + else + throw Exiv2::Error(METADATA_NOT_READ); + } + boost::python::tuple Image::getIptcTag(std::string key) { if(_dataRead) diff --git a/src/libpyexiv2.hpp b/src/libpyexiv2.hpp index 53cf532..559213d 100644 --- a/src/libpyexiv2.hpp +++ b/src/libpyexiv2.hpp @@ -56,6 +56,9 @@ namespace LibPyExiv2 // image. boost::python::list getAvailableExifTags(); + // Return true if the required EXIF tag is set, false otherwise. + bool isExifTagSet(std::string key); + // Returns a tuple containing the type (as a string) and the value // (as a string as well) of the required EXIF tag, empty strings if // the tag does not exist. @@ -82,6 +85,9 @@ namespace LibPyExiv2 // image. boost::python::list getAvailableIptcTags(); + // Return true if the required IPTC tag is set, false otherwise. + bool isIptcTagSet(std::string key); + // Returns a tuple containing the type (as a string) and the value // (as a string as well) of the required IPTC tag, empty strings if // the tag does not exist. diff --git a/src/libpyexiv2_wrapper.cpp b/src/libpyexiv2_wrapper.cpp index aac281b..16c54ea 100644 --- a/src/libpyexiv2_wrapper.cpp +++ b/src/libpyexiv2_wrapper.cpp @@ -40,11 +40,13 @@ BOOST_PYTHON_MODULE(libpyexiv2) .def("readMetadata", &Image::readMetadata) .def("writeMetadata", &Image::writeMetadata) .def("getAvailableExifTags", &Image::getAvailableExifTags) + .def("isExifTagSet", &Image::isExifTagSet) .def("getExifTag", &Image::getExifTag) .def("getExifTagToString", &Image::getExifTagToString) .def("setExifTag", &Image::setExifTag) .def("deleteExifTag", &Image::deleteExifTag) .def("getAvailableIptcTags", &Image::getAvailableIptcTags) + .def("isIptcTagSet", &Image::isIptcTagSet) .def("getIptcTag", &Image::getIptcTag) .def("setIptcTag", &Image::setIptcTag) .def("deleteIptcTag", &Image::deleteIptcTag) |