aboutsummaryrefslogtreecommitdiffstats
path: root/src/exiv2wrapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/exiv2wrapper.cpp')
-rw-r--r--src/exiv2wrapper.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/exiv2wrapper.cpp b/src/exiv2wrapper.cpp
index 914657a..3dbd8b2 100644
--- a/src/exiv2wrapper.cpp
+++ b/src/exiv2wrapper.cpp
@@ -398,6 +398,24 @@ void Image::deleteXmpTag(std::string key)
throw Exiv2::Error(KEY_NOT_FOUND, key);
}
+boost::python::list Image::previews()
+{
+ CHECK_METADATA_READ
+
+ boost::python::list previews;
+ Exiv2::PreviewManager pm(*_image);
+ Exiv2::PreviewPropertiesList props = pm.getPreviewProperties();
+ for (Exiv2::PreviewPropertiesList::const_iterator i = props.begin();
+ i != props.end();
+ ++i)
+ {
+ previews.append(Preview(pm.getPreviewImage(*i)));
+ }
+
+ return previews;
+}
+
+
/*
boost::python::tuple Image::getThumbnailData()
{
@@ -774,6 +792,29 @@ const boost::python::dict XmpTag::getLangAltValue()
}
+Preview::Preview(const Exiv2::PreviewImage& previewImage)
+{
+ _mimeType = previewImage.mimeType();
+ _extension = previewImage.extension();
+ _size = previewImage.size();
+ _dimensions = boost::python::make_tuple(previewImage.width(),
+ previewImage.height());
+ // Copy the data buffer in a string. Since the data buffer can contain null
+ // characters ('\x00'), the string cannot be simply constructed like that:
+ // _data = std::string((char*) previewImage.pData());
+ // because it would be truncated after the first occurence of a null
+ // character. Therefore, it has to be copied character by character.
+ const Exiv2::byte* pData = previewImage.pData();
+ // First allocate the memory for the whole string...
+ _data = std::string(_size, ' ');
+ // ... then fill it with the raw data.
+ for(unsigned int i = 0; i < _size; ++i)
+ {
+ _data[i] = pData[i];
+ }
+}
+
+
// TODO: update the errors code to reflect changes from src/error.cpp in libexiv2
void translateExiv2Error(Exiv2::Error const& error)
{