aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2007-01-07 22:18:30 +0100
committerOlivier Tilloy <olivier@tilloy.net>2007-01-07 22:18:30 +0100
commit7ef926c1493c544d75e805a149999987d6146597 (patch)
treea10efd544382ab5702468cccce9d00d660d3777b
parent559735fd514a3f29c12870e60be8d878a5bc97be (diff)
downloadpyexiv2-7ef926c1493c544d75e805a149999987d6146597.tar.gz
Added method Image::setThumbnailFromJpegFile(...) that allows setting the image thumbnail from a jpeg file.
-rw-r--r--src/libpyexiv2.cpp22
-rw-r--r--src/libpyexiv2.hpp5
-rw-r--r--src/libpyexiv2_wrapper.cpp1
-rw-r--r--src/todo3
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)
;
}
diff --git a/src/todo b/src/todo
index 52bda27..0ea0952 100644
--- a/src/todo
+++ b/src/todo
@@ -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