diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2007-01-07 22:18:30 +0100 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2007-01-07 22:18:30 +0100 |
commit | 7ef926c1493c544d75e805a149999987d6146597 (patch) | |
tree | a10efd544382ab5702468cccce9d00d660d3777b | |
parent | 559735fd514a3f29c12870e60be8d878a5bc97be (diff) | |
download | pyexiv2-7ef926c1493c544d75e805a149999987d6146597.tar.gz |
Added method Image::setThumbnailFromJpegFile(...) that allows setting the image thumbnail from a jpeg file.
-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 |