diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2007-01-20 21:48:08 +0100 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2007-01-20 21:48:08 +0100 |
commit | cee5027a0d0881610a362d2ea1baee91d5489b1f (patch) | |
tree | 4f14d531ec485fe490848427e8f31c96ed4ff99c /src | |
parent | a0492164d90727aa26f2a1849fb82697dda3d0ab (diff) | |
download | pyexiv2-cee5027a0d0881610a362d2ea1baee91d5489b1f.tar.gz |
Added two methods to class Image, isExifTagSet() and isIptcTagSet(), to determine whether a tag is set.
Diffstat (limited to 'src')
-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) |