Exiv2
preview.hpp
Go to the documentation of this file.
1 // ***************************************************************** -*- C++ -*-
2 /*
3  * Copyright (C) 2004-2018 Exiv2 authors
4  * This program is part of the Exiv2 distribution.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
19  */
27 #ifndef PREVIEW_HPP_
28 #define PREVIEW_HPP_
29 
30 // *****************************************************************************
31 #include "exiv2lib_export.h"
32 
33 #include "image.hpp"
34 
35 // *****************************************************************************
36 // namespace extensions
37 namespace Exiv2 {
38 
39 // *****************************************************************************
40 // class definitions
41 
43  typedef int PreviewId;
44 
48  struct EXIV2API PreviewProperties {
53 #ifdef EXV_UNICODE_PATH
54  std::wstring wextension_;
56 #endif
57  uint32_t size_;
60  uint32_t width_;
62  uint32_t height_;
65  };
66 
68  typedef std::vector<PreviewProperties> PreviewPropertiesList;
69 
73  class EXIV2API PreviewImage {
74  friend class PreviewManager;
75  public:
77 
78  PreviewImage(const PreviewImage& rhs);
81  ~PreviewImage();
83 
85 
86  PreviewImage& operator=(const PreviewImage& rhs);
89 
91 
92 
96  DataBuf copy() const;
100  const byte* pData() const;
104  uint32_t size() const;
115  long writeFile(const std::string& path) const;
116 #ifdef EXV_UNICODE_PATH
117 
121  long writeFile(const std::wstring& wpath) const;
122 #endif
123 
127  std::string mimeType() const;
132  std::string extension() const;
133 #ifdef EXV_UNICODE_PATH
134 
139  std::wstring wextension() const;
140 #endif
141 
144  uint32_t width() const;
148  uint32_t height() const;
152  PreviewId id() const;
154 
155  private:
157  PreviewImage(const PreviewProperties& properties, DataBuf data);
158 
159  PreviewProperties properties_;
160  byte* pData_;
161  uint32_t size_;
162 
163  }; // class PreviewImage
164 
168  class EXIV2API PreviewManager {
169  public:
171 
172  explicit PreviewManager(const Image& image);
175 
177 
178 
183  PreviewPropertiesList getPreviewProperties() const;
187  PreviewImage getPreviewImage(const PreviewProperties& properties) const;
189 
190  private:
191  const Image& image_;
192 
193  }; // class PreviewManager
194 } // namespace Exiv2
195 
196 #endif // #ifndef PREVIEW_HPP_
Exiv2::BasicIo::open
virtual int open()=0
Open the IO source using the default access mode. The default mode should allow for reading and writi...
Exiv2::MemIo
Provides binary IO on blocks of memory by implementing the BasicIo interface. A copy-on-write impleme...
Definition: basicio.hpp:540
Exiv2::DataBuf::pData_
byte * pData_
Pointer to the buffer, 0 if none has been allocated.
Definition: types.hpp:269
Exiv2::IoCloser
Utility class that closes a BasicIo instance upon destruction. Meant to be used as a stack variable i...
Definition: basicio.hpp:264
Exiv2::ExifData::findKey
iterator findKey(const ExifKey &key)
Find the first Exifdatum with the given key, return an iterator to it.
Definition: exif.cpp:590
Exiv2::Value
Common interface for all types of values used with metadata.
Definition: value.hpp:60
Exiv2::ExifData::add
void add(const ExifKey &key, const Value *pValue)
Add an Exifdatum from the supplied key and value pair. This method copies (clones) key and value....
Definition: exif.cpp:573
Exiv2::PreviewImage::id
PreviewId id() const
Return the preview image type identifier.
Definition: preview.cpp:1134
Exiv2::ExifData::begin
iterator begin()
Begin of the metadata.
Definition: exif.hpp:490
Exiv2::PreviewManager::PreviewManager
PreviewManager(const Image &image)
Constructor.
Definition: preview.cpp:1139
Exiv2::ExifData::const_iterator
ExifMetadata::const_iterator const_iterator
ExifMetadata const iterator type.
Definition: exif.hpp:439
Exiv2::PreviewImage::writeFile
long writeFile(const std::string &path) const
Write the thumbnail image to a file.
Definition: preview.cpp:1074
Exiv2::undefined
@ undefined
Exif UNDEFINED type, an 8-bit byte that may contain anything.
Definition: types.hpp:137
Exiv2::DataBuf::release
EXV_WARN_UNUSED_RESULT std::pair< byte *, long > release()
Release ownership of the buffer to the caller. Returns the buffer as a data pointer and size pair,...
Definition: types.cpp:172
Exiv2::NativePreview
Native preview information. This is meant to be used only by the PreviewManager.
Definition: image.hpp:52
Exiv2::writeFile
EXIV2API long writeFile(const DataBuf &buf, const std::string &path)
Write DataBuf buf to file path.
Definition: basicio.cpp:2701
Exiv2::AnyError
Error class interface. Allows the definition and use of a hierarchy of error classes which can all be...
Definition: error.hpp:174
Exiv2::Image::nativePreviews
const NativePreviewList & nativePreviews() const
Return list of native previews. This is meant to be used only by the PreviewManager.
Definition: image.cpp:741
Exiv2::strError
EXIV2API std::string strError()
Return a system error message and the error code (errno). See strerror(3).
Definition: futils.cpp:356
Exiv2::PreviewProperties::height_
uint32_t height_
Preview image height in pixels or 0 for unknown height.
Definition: preview.hpp:62
Exiv2::PreviewPropertiesList
std::vector< PreviewProperties > PreviewPropertiesList
Container type to hold all preview images metadata.
Definition: preview.hpp:68
Exiv2::PreviewProperties
Preview image properties.
Definition: preview.hpp:48
Exiv2::Value::count
virtual long count() const =0
Return the number of components of the value.
EXV_COUNTOF
#define EXV_COUNTOF(a)
Macro to determine the size of an array.
Definition: types.hpp:517
Exiv2::ExifData::end
iterator end()
End of the metadata.
Definition: exif.hpp:492
Exiv2::XmpKey
Concrete keys for XMP metadata.
Definition: properties.hpp:242
cr2image.hpp
Class Cr2Image.
Exiv2::PreviewImage::width
uint32_t width() const
Return the width of the preview image in pixels.
Definition: preview.cpp:1124
Exiv2::PreviewImage::height
uint32_t height() const
Return the height of the preview image in pixels.
Definition: preview.cpp:1129
Exiv2::XmpData::findKey
iterator findKey(const XmpKey &key)
Find the first Xmpdatum with the given key, return an iterator to it.
Definition: xmp.cpp:339
enforce.hpp
Port of D's enforce() to C++ & Exiv2.
Exiv2::PreviewImage::pData
const byte * pData() const
Return a pointer to the image data for read-only access.
Definition: preview.cpp:1097
Exiv2::PreviewProperties::size_
uint32_t size_
Preview image size in bytes.
Definition: preview.hpp:58
preview.hpp
Classes to access all preview images embedded in an image.
tiffimage_int.hpp
Internal class TiffParserWorker to parse TIFF data.
Exiv2::byte
uint8_t byte
1 byte unsigned integer type.
Definition: types.hpp:105
enforce
void enforce(bool condition, const T &arg1)
Ensure that condition is true, otherwise throw an exception of the type exception_t.
Definition: enforce.hpp:43
Exiv2::DataBuf
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition: types.hpp:204
Exiv2::PreviewManager::getPreviewProperties
PreviewPropertiesList getPreviewProperties() const
Return the properties of all preview images in a list sorted by preview width * height,...
Definition: preview.cpp:1144
Exiv2::ExifKey
Concrete keys for Exif metadata and access to Exif tag reference data.
Definition: tags.hpp:148
Exiv2::PreviewId
int PreviewId
Type of preview image.
Definition: preview.hpp:43
Exiv2::DataBuf::size_
long size_
The current size of the buffer.
Definition: types.hpp:271
Exiv2::Value::toLong
virtual long toLong(long n=0) const =0
Convert the n-th component of the value to a long. The behaviour of this method may be undefined if t...
Exiv2::Value::setDataArea
virtual int setDataArea(const byte *buf, long len)
Set the data area, if the value has one by copying (cloning) the buffer pointed to by buf.
Definition: value.cpp:170
Exiv2
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
Exiv2::XmpData
A container for XMP data. This is a top-level class of the Exiv2 library.
Definition: xmp_exiv2.hpp:173
Exiv2::PreviewImage::PreviewImage
PreviewImage(const PreviewImage &rhs)
Copy constructor.
Definition: preview.cpp:1053
Exiv2::PreviewProperties::width_
uint32_t width_
Preview image width in pixels or 0 for unknown width.
Definition: preview.hpp:60
image.hpp
Exiv2::BasicIo::path
virtual std::string path() const =0
Return the path to the IO resource. Often used to form comprehensive error messages where only a Basi...
Exiv2::PreviewManager::getPreviewImage
PreviewImage getPreviewImage(const PreviewProperties &properties) const
Return the preview image for the given preview properties.
Definition: preview.cpp:1161
safe_op.hpp
Overflow checks for integers.
EXV_WARNING
#define EXV_WARNING
Shorthand for a temp warning log message object and return its ostringstream.
Definition: error.hpp:148
Exiv2::XmpData::const_iterator
XmpMetadata::const_iterator const_iterator
XmpMetadata const iterator type.
Definition: xmp_exiv2.hpp:181
Exiv2::PreviewImage
Class that holds preview image properties and data buffer.
Definition: preview.hpp:73
Exiv2::BasicIo::mmap
virtual byte * mmap(bool isWriteable=false)=0
Direct access to the IO data. For files, this is done by mapping the file into the process's address ...
Exiv2::BasicIo::size
virtual size_t size() const =0
Get the current size of the IO source in bytes.
Exiv2::PreviewProperties::extension_
std::string extension_
Preview image extension.
Definition: preview.hpp:52
Exiv2::Image::AutoPtr
std::auto_ptr< Image > AutoPtr
Image auto_ptr type.
Definition: image.hpp:84
Safe::add
T add(T summand_1, T summand_2)
Safe addition, throws an exception on overflow.
Definition: safe_op.hpp:295
Exiv2::Error
BasicError< char > Error
Error class used for exceptions (std::string based)
Definition: error.hpp:323
Exiv2::Value::sizeDataArea
virtual long sizeDataArea() const
Return the size of the data area, 0 if there is none.
Definition: value.cpp:188
Exiv2::MemIo::mmap
virtual byte * mmap(bool=false)
Allow direct access to the underlying data buffer. The buffer is not protected against write access i...
Definition: basicio.cpp:1338
Exiv2::IptcData
A container for IPTC data. This is a top-level class of the Exiv2 library.
Definition: iptc.hpp:173
Exiv2::PreviewImage::mimeType
std::string mimeType() const
Return the MIME type of the preview image, usually either "image/tiff" or "image/jpeg".
Definition: preview.cpp:1107
Exiv2::string
@ string
IPTC string type.
Definition: types.hpp:147
Exiv2::PreviewProperties::mimeType_
std::string mimeType_
Preview image mime type.
Definition: preview.hpp:50
Exiv2::PreviewImage::copy
DataBuf copy() const
Return a copy of the preview image data. The caller owns this copy and DataBuf ensures that it will b...
Definition: preview.cpp:1092
Exiv2::PreviewImage::extension
std::string extension() const
Return the file extension for the format of the preview image (".tif" or ".jpg").
Definition: preview.cpp:1112
Exiv2::PreviewManager
Class for extracting preview images from image metadata.
Definition: preview.hpp:168
Exiv2::MemIo::size
virtual size_t size() const
Get the current memory buffer size in bytes.
Definition: basicio.cpp:1353
Exiv2::Image::mimeType
virtual std::string mimeType() const =0
Return the MIME type of the image.
Exiv2::PreviewProperties::id_
PreviewId id_
Identifies type of preview image.
Definition: preview.hpp:64
Exiv2::toString
std::string toString(const T &arg)
Utility function to convert the argument of any type to a string.
Definition: types.hpp:521
Exiv2::PreviewImage::size
uint32_t size() const
Return the size of the preview image in bytes.
Definition: preview.cpp:1102
Exiv2::BasicIo
An interface for simple binary IO.
Definition: basicio.hpp:55
Exiv2::Image
Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2...
Definition: image.hpp:81
Exiv2::XmpData::end
iterator end()
End of the metadata.
Definition: xmp.cpp:380
futils.hpp
Basic file utility functions required by Exiv2.
jpgimage.hpp
Class JpegImage to access JPEG images.
Exiv2::PreviewImage::operator=
PreviewImage & operator=(const PreviewImage &rhs)
Assignment operator.
Definition: preview.cpp:1061
Exiv2::ExifData
A container for Exif data. This is a top-level class of the Exiv2 library. The container holds Exifda...
Definition: exif.hpp:434