From 35bf3a8dcc8812a9956108f9b401f478cadc60f7 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Wed, 3 Jan 2007 23:01:30 +0100 Subject: Implemented Image::setThumbnailData() that sets the thumbnail embedded in an image from raw jpeg data. --- src/libpyexiv2.cpp | 17 +++++++++++++---- src/libpyexiv2.hpp | 7 +++---- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/libpyexiv2.cpp b/src/libpyexiv2.cpp index 79e8959..76c06ed 100644 --- a/src/libpyexiv2.cpp +++ b/src/libpyexiv2.cpp @@ -23,7 +23,7 @@ Author(s): Olivier Tilloy History: 28-Dec-06, Olivier Tilloy: created 30-Dec-06, Olivier Tilloy: implemented IPTC-related methods - 03-Jan-07, Olivier Tilloy: implemented getThumbnailData() + 03-Jan-07, Olivier Tilloy: implemented thumbnail-related methods */ // ***************************************************************************** @@ -434,10 +434,19 @@ namespace LibPyExiv2 } } - bool Image::setThumbnailData(boost::python::tuple data) + bool Image::setThumbnailData(std::string data) { - //TODO - return true; + if(_dataRead) + { + const Exiv2::byte* dataBuf = (const Exiv2::byte*) data.c_str(); + _exifData.setJpegThumbnail(dataBuf, data.size()); + return true; + } + else + { + std::cerr << ">>> Image::setThumbnailData(): 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 61f46b4..91956cc 100644 --- a/src/libpyexiv2.hpp +++ b/src/libpyexiv2.hpp @@ -104,11 +104,10 @@ namespace LibPyExiv2 // "JPEG") and the thumbnail raw data as a string buffer. boost::python::tuple getThumbnailData(); - // Sets the thumbnail of the image. The first element of the tuple is - // the format of the thumbnail ("TIFF" or "JPEG") and the second element - // is the thumbnail raw data as a string buffer. + // Sets the thumbnail of the image. The parameter is the thumbnail raw + // jpeg data as a string buffer. // Returns true if successful, false otherwise. - bool setThumbnailData(boost::python::tuple data); + bool setThumbnailData(std::string data); private: std::string _filename; -- cgit