diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libpyexiv2.cpp | 22 | ||||
-rw-r--r-- | src/libpyexiv2.hpp | 5 | ||||
-rw-r--r-- | src/libpyexiv2_wrapper.cpp | 1 | ||||
-rw-r--r-- | src/todo | 3 |
4 files changed, 30 insertions, 1 deletions
diff --git a/src/libpyexiv2.cpp b/src/libpyexiv2.cpp index 389f2c1..2c8fb4d 100644 --- a/src/libpyexiv2.cpp +++ b/src/libpyexiv2.cpp @@ -493,4 +493,26 @@ namespace LibPyExiv2 } } + bool Image::setThumbnailFromJpegFile(const std::string path) + { + if(_dataRead) + { + try + { + _exifData.setJpegThumbnail(path); + return true; + } + catch(Exiv2::Error& e) + { + std::cerr << ">>> Image::setThumbnailFromJpegFile(): caught Exiv2 exception '" << e << "'"; + return false; + } + } + else + { + std::cerr << ">>> Image::setThumbnailFromJpegFile(): metadata not read yet, call Image::readMetadata() first" << std::endl; + return false; + } + } + } // End of namespace LibPyExiv2 diff --git a/src/libpyexiv2.hpp b/src/libpyexiv2.hpp index 217da50..a4bb735 100644 --- a/src/libpyexiv2.hpp +++ b/src/libpyexiv2.hpp @@ -119,6 +119,11 @@ namespace LibPyExiv2 // Returns true if successful, false otherwise. bool dumpThumbnailToFile(const std::string path); + // Sets the image contained in the jpeg file passed as a parameter as + // the thumbnail of the image. + // Returns true if successful, false otherwise. + bool setThumbnailFromJpegFile(const std::string path); + private: std::string _filename; Exiv2::Image::AutoPtr _image; diff --git a/src/libpyexiv2_wrapper.cpp b/src/libpyexiv2_wrapper.cpp index 7e00760..a84cd11 100644 --- a/src/libpyexiv2_wrapper.cpp +++ b/src/libpyexiv2_wrapper.cpp @@ -52,5 +52,6 @@ BOOST_PYTHON_MODULE(libpyexiv2) .def("setThumbnailData", &Image::setThumbnailData) .def("deleteThumbnail", &Image::deleteThumbnail) .def("dumpThumbnailToFile", &Image::dumpThumbnailToFile) + .def("setThumbnailFromJpegFile", &Image::setThumbnailFromJpegFile) ; } @@ -1,5 +1,6 @@ todo list -- Add support for thumbnail extraction - Add extensive unit tests - Document the binding +- Provide examples on how to use the thumbnail extraction features with pygtk + and pyqt |