Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2 library. More...
#include <image.hpp>
Public Types | |
typedef std::auto_ptr< Image > | AutoPtr |
Image auto_ptr type. | |
Public Member Functions | |
Creators | |
Image (int imageType, uint16_t supportedMetadata, BasicIo::AutoPtr io) | |
Constructor taking the image type, a bitmap of the supported metadata types and an auto-pointer that owns an IO instance. See subclass constructor doc. | |
virtual | ~Image () |
Virtual Destructor. | |
Manipulators | |
virtual void | printStructure (std::ostream &out, PrintStructureOption option=kpsNone, int depth=0) |
Print out the structure of image file. More... | |
virtual void | readMetadata ()=0 |
Read all metadata supported by a specific image format from the image. Before this method is called, the image metadata will be cleared. More... | |
virtual void | writeMetadata ()=0 |
Write metadata back to the image. More... | |
virtual void | setExifData (const ExifData &exifData) |
Assign new Exif data. The new Exif data is not written to the image until the writeMetadata() method is called. More... | |
virtual void | clearExifData () |
Erase any buffered Exif data. Exif data is not removed from the actual image until the writeMetadata() method is called. | |
virtual void | setIptcData (const IptcData &iptcData) |
Assign new IPTC data. The new IPTC data is not written to the image until the writeMetadata() method is called. More... | |
virtual void | clearIptcData () |
Erase any buffered IPTC data. IPTC data is not removed from the actual image until the writeMetadata() method is called. | |
virtual void | setXmpPacket (const std::string &xmpPacket) |
Assign a raw XMP packet. The new XMP packet is not written to the image until the writeMetadata() method is called. More... | |
virtual void | clearXmpPacket () |
Erase the buffered XMP packet. XMP data is not removed from the actual image until the writeMetadata() method is called. More... | |
virtual void | setXmpData (const XmpData &xmpData) |
Assign new XMP data. The new XMP data is not written to the image until the writeMetadata() method is called. More... | |
virtual void | clearXmpData () |
Erase any buffered XMP data. XMP data is not removed from the actual image until the writeMetadata() method is called. More... | |
virtual void | setComment (const std::string &comment) |
Set the image comment. The new comment is not written to the image until the writeMetadata() method is called. More... | |
virtual void | clearComment () |
Erase any buffered comment. Comment is not removed from the actual image until the writeMetadata() method is called. | |
virtual void | setIccProfile (DataBuf &iccProfile, bool bTestValid=true) |
Set the image iccProfile. The new profile is not written to the image until the writeMetadata() method is called. More... | |
virtual void | clearIccProfile () |
Erase iccProfile. the profile is not removed from the actual image until the writeMetadata() method is called. | |
virtual bool | iccProfileDefined () |
Erase iccProfile. the profile is not removed from the actual image until the writeMetadata() method is called. | |
virtual DataBuf * | iccProfile () |
return iccProfile | |
virtual void | setMetadata (const Image &image) |
Copy all existing metadata from source Image. The data is copied into internal buffers and is not written to the image until the writeMetadata() method is called. More... | |
virtual void | clearMetadata () |
Erase all buffered metadata. Metadata is not removed from the actual image until the writeMetadata() method is called. | |
virtual ExifData & | exifData () |
Returns an ExifData instance containing currently buffered Exif data. More... | |
virtual IptcData & | iptcData () |
Returns an IptcData instance containing currently buffered IPTC data. More... | |
virtual XmpData & | xmpData () |
Returns an XmpData instance containing currently buffered XMP data. More... | |
virtual std::string & | xmpPacket () |
Return a modifiable reference to the raw XMP packet. | |
void | writeXmpFromPacket (bool flag) |
Determine the source when writing XMP. More... | |
void | setByteOrder (ByteOrder byteOrder) |
Set the byte order to encode the Exif metadata in. More... | |
void | printTiffStructure (BasicIo &io, std::ostream &out, PrintStructureOption option, int depth, size_t offset=0) |
Print out the structure of image file. More... | |
void | printIFDStructure (BasicIo &io, std::ostream &out, Exiv2::PrintStructureOption option, uint32_t start, bool bSwap, char c, int depth) |
Print out the structure of a TIFF IFD. | |
bool | isBigEndianPlatform () |
is the host platform bigEndian | |
bool | isLittleEndianPlatform () |
is the host platform littleEndian | |
bool | isStringType (uint16_t type) |
bool | isShortType (uint16_t type) |
bool | isLongType (uint16_t type) |
bool | isLongLongType (uint16_t type) |
bool | isRationalType (uint16_t type) |
bool | is2ByteType (uint16_t type) |
bool | is4ByteType (uint16_t type) |
bool | is8ByteType (uint16_t type) |
bool | isPrintXMP (uint16_t type, Exiv2::PrintStructureOption option) |
bool | isPrintICC (uint16_t type, Exiv2::PrintStructureOption option) |
uint64_t | byteSwap (uint64_t value, bool bSwap) const |
uint32_t | byteSwap (uint32_t value, bool bSwap) const |
uint16_t | byteSwap (uint16_t value, bool bSwap) const |
uint16_t | byteSwap2 (const DataBuf &buf, size_t offset, bool bSwap) const |
uint32_t | byteSwap4 (const DataBuf &buf, size_t offset, bool bSwap) const |
uint64_t | byteSwap8 (const DataBuf &buf, size_t offset, bool bSwap) const |
Accessors | |
BasicIo::AutoPtr | io_ |
Image data IO pointer. | |
ExifData | exifData_ |
Exif data container. | |
IptcData | iptcData_ |
IPTC data container. | |
XmpData | xmpData_ |
XMP data container. | |
DataBuf | iccProfile_ |
ICC buffer (binary data) | |
std::string | comment_ |
User comment. | |
std::string | xmpPacket_ |
XMP packet. | |
int | pixelWidth_ |
image pixel width | |
int | pixelHeight_ |
image pixel height | |
NativePreviewList | nativePreviews_ |
list of native previews | |
ByteOrder | byteOrder () const |
Return the byte order in which the Exif metadata of the image is encoded. Initially, it is not set (invalidByteOrder). | |
bool | good () const |
Check if the Image instance is valid. Use after object construction. More... | |
virtual std::string | mimeType () const =0 |
Return the MIME type of the image. More... | |
virtual int | pixelWidth () const |
Return the pixel width of the image. | |
virtual int | pixelHeight () const |
Return the pixel height of the image. | |
virtual const ExifData & | exifData () const |
Returns an ExifData instance containing currently buffered Exif data. More... | |
virtual const IptcData & | iptcData () const |
Returns an IptcData instance containing currently buffered IPTC data. More... | |
virtual const XmpData & | xmpData () const |
Returns an XmpData instance containing currently buffered XMP data. More... | |
virtual std::string | comment () const |
Return a copy of the image comment. May be an empty string. | |
virtual const std::string & | xmpPacket () const |
Return the raw XMP packet as a string. | |
virtual BasicIo & | io () const |
Return a reference to the BasicIo instance being used for Io. More... | |
AccessMode | checkMode (MetadataId metadataId) const |
Returns the access mode, i.e., the metadata functions, which this image supports for the metadata type metadataId. More... | |
bool | supportsMetadata (MetadataId metadataId) const |
Check if image supports a particular type of metadata. This method is deprecated. Use checkMode() instead. | |
bool | writeXmpFromPacket () const |
Return the flag indicating the source when writing XMP metadata. | |
const NativePreviewList & | nativePreviews () const |
Return list of native previews. This is meant to be used only by the PreviewManager. | |
void | setTypeSupported (int imageType, uint16_t supportedMetadata) |
set type support for this image format | |
int | imageType () const |
set type support for this image format | |
const std::string & | tagName (uint16_t tag) |
Return tag name for given tag id. | |
const char * | typeName (uint16_t tag) const |
Return tag type for given tag id. | |
Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2 library.
Image has containers to store image metadata and subclasses implement read and save metadata from and to specific image formats.
Most client apps will obtain an Image instance by calling a static ImageFactory method. The Image class can then be used to to read, write, and save metadata.
AccessMode Exiv2::Image::checkMode | ( | MetadataId | metadataId | ) | const |
Returns the access mode, i.e., the metadata functions, which this image supports for the metadata type metadataId.
metadataId | The metadata identifier. |
|
virtual |
Erase any buffered XMP data. XMP data is not removed from the actual image until the writeMetadata() method is called.
This has the same effect as clearXmpPacket() but operates on the buffered parsed XMP data.
Subsequent calls to writeMetadata() encode the XMP data to a raw XMP packet and write the newly encoded packet to the image. In the process, the buffered raw XMP packet is updated. In order to write directly from the raw XMP packet, use writeXmpFromPacket(true) or setXmpPacket().
|
virtual |
Erase the buffered XMP packet. XMP data is not removed from the actual image until the writeMetadata() method is called.
This has the same effect as clearXmpData() but operates on the buffered raw XMP packet only, not the parsed XMP data.
Subsequent calls to writeMetadata() write the XMP packet from the buffered raw XMP packet rather than from buffered parsed XMP data. In order to write from parsed XMP data again, use either writeXmpFromPacket(false) or setXmpData().
|
virtual |
Returns an ExifData instance containing currently buffered Exif data.
The contained Exif data may have been read from the image by a previous call to readMetadata() or added directly. The Exif data in the returned instance will be written to the image when writeMetadata() is called.
|
virtual |
Returns an ExifData instance containing currently buffered Exif data.
The Exif data may have been read from the image by a previous call to readMetadata() or added directly. The Exif data in the returned instance will be written to the image when writeMetadata() is called.
bool Exiv2::Image::good | ( | ) | const |
|
virtual |
Return a reference to the BasicIo instance being used for Io.
This refence is particularly useful to reading the results of operations on a MemIo instance. For example after metadata has been modified and the writeMetadata() method has been called, this method can be used to get access to the modified image.
|
virtual |
Returns an IptcData instance containing currently buffered IPTC data.
The contained IPTC data may have been read from the image by a previous call to readMetadata() or added directly. The IPTC data in the returned instance will be written to the image when writeMetadata() is called.
|
virtual |
Returns an IptcData instance containing currently buffered IPTC data.
The contained IPTC data may have been read from the image by a previous call to readMetadata() or added directly. The IPTC data in the returned instance will be written to the image when writeMetadata() is called.
|
pure virtual |
Return the MIME type of the image.
Implemented in Exiv2::ExvImage, Exiv2::JpegImage, Exiv2::BmffImage, Exiv2::BmpImage, Exiv2::RafImage, Exiv2::GifImage, Exiv2::TgaImage, Exiv2::TiffImage, Exiv2::Cr2Image, Exiv2::CrwImage, Exiv2::Jp2Image, Exiv2::MrwImage, Exiv2::PsdImage, Exiv2::EpsImage, Exiv2::Rw2Image, Exiv2::PngImage, Exiv2::MatroskaVideo, Exiv2::OrfImage, Exiv2::WebPImage, Exiv2::PgfImage, Exiv2::XmpSidecar, Exiv2::AsfVideo, Exiv2::RiffVideo, and Exiv2::QuickTimeVideo.
|
virtual |
Print out the structure of image file.
Error | if reading of the file fails or the image data is not valid (does not look like data of the specific image type). |
Reimplemented in Exiv2::TiffImage, Exiv2::JpegBase, Exiv2::Cr2Image, Exiv2::Jp2Image, Exiv2::PngImage, Exiv2::RafImage, Exiv2::OrfImage, Exiv2::Rw2Image, Exiv2::WebPImage, Exiv2::RiffVideo, and Exiv2::BmffImage.
void Exiv2::Image::printTiffStructure | ( | BasicIo & | io, |
std::ostream & | out, | ||
PrintStructureOption | option, | ||
int | depth, | ||
size_t | offset = 0 |
||
) |
Print out the structure of image file.
Error | if reading of the file fails or the image data is not valid (does not look like data of the specific image type). |
|
pure virtual |
Read all metadata supported by a specific image format from the image. Before this method is called, the image metadata will be cleared.
This method returns success even if no metadata is found in the image. Callers must therefore check the size of individual metadata types before accessing the data.
Error | if opening or reading of the file fails or the image data is not valid (does not look like data of the specific image type). |
Implemented in Exiv2::JpegBase, Exiv2::BmffImage, Exiv2::CrwImage, Exiv2::EpsImage, Exiv2::BmpImage, Exiv2::Cr2Image, Exiv2::MatroskaVideo, Exiv2::TiffImage, Exiv2::RafImage, Exiv2::GifImage, Exiv2::Jp2Image, Exiv2::TgaImage, Exiv2::PsdImage, Exiv2::PgfImage, Exiv2::PngImage, Exiv2::AsfVideo, Exiv2::OrfImage, Exiv2::MrwImage, Exiv2::Rw2Image, Exiv2::RiffVideo, Exiv2::QuickTimeVideo, Exiv2::XmpSidecar, and Exiv2::WebPImage.
void Exiv2::Image::setByteOrder | ( | ByteOrder | byteOrder | ) |
Set the byte order to encode the Exif metadata in.
The setting is only used when new Exif metadata is created and may not be applicable at all for some image formats. If the target image already contains Exif metadata, the byte order of the existing data is used. If byte order is not set when writeMetadata() is called, little-endian byte order (II) is used by default.
|
virtual |
Set the image comment. The new comment is not written to the image until the writeMetadata() method is called.
comment | String containing comment. |
Reimplemented in Exiv2::BmffImage, Exiv2::BmpImage, Exiv2::RafImage, Exiv2::GifImage, Exiv2::TgaImage, Exiv2::TiffImage, Exiv2::Cr2Image, Exiv2::Jp2Image, Exiv2::MrwImage, Exiv2::EpsImage, Exiv2::Rw2Image, Exiv2::PsdImage, Exiv2::OrfImage, Exiv2::WebPImage, and Exiv2::XmpSidecar.
|
virtual |
Assign new Exif data. The new Exif data is not written to the image until the writeMetadata() method is called.
exifData | An ExifData instance holding Exif data to be copied |
Reimplemented in Exiv2::BmpImage, Exiv2::RafImage, Exiv2::GifImage, Exiv2::TgaImage, Exiv2::MrwImage, and Exiv2::Rw2Image.
|
virtual |
Set the image iccProfile. The new profile is not written to the image until the writeMetadata() method is called.
iccProfile | DataBuf containing profile (binary) |
bTestValid | - tests that iccProfile contains credible data |
|
virtual |
Assign new IPTC data. The new IPTC data is not written to the image until the writeMetadata() method is called.
iptcData | An IptcData instance holding IPTC data to be copied |
Reimplemented in Exiv2::BmpImage, Exiv2::RafImage, Exiv2::CrwImage, Exiv2::GifImage, Exiv2::TgaImage, Exiv2::MrwImage, Exiv2::Rw2Image, and Exiv2::WebPImage.
|
virtual |
Copy all existing metadata from source Image. The data is copied into internal buffers and is not written to the image until the writeMetadata() method is called.
image | Metadata source. All metadata types are copied. |
|
virtual |
Assign new XMP data. The new XMP data is not written to the image until the writeMetadata() method is called.
Subsequent calls to writeMetadata() encode the XMP data to a raw XMP packet and write the newly encoded packet to the image. In the process, the buffered raw XMP packet is updated. In order to write directly from the raw XMP packet, use writeXmpFromPacket(true) or setXmpPacket().
xmpData | An XmpData instance holding XMP data to be copied |
|
virtual |
Assign a raw XMP packet. The new XMP packet is not written to the image until the writeMetadata() method is called.
Subsequent calls to writeMetadata() write the XMP packet from the buffered raw XMP packet rather than from buffered parsed XMP data. In order to write from parsed XMP data again, use either writeXmpFromPacket(false) or setXmpData().
xmpPacket | A string containing the raw XMP packet. |
|
pure virtual |
Write metadata back to the image.
All existing metadata sections in the image are either created, replaced, or erased. If values for a given metadata type have been assigned, a section for that metadata type will either be created or replaced. If no values have been assigned to a given metadata type, any exists section for that metadata type will be removed from the image.
Error | if the operation fails |
Implemented in Exiv2::JpegBase, Exiv2::BmffImage, Exiv2::BmpImage, Exiv2::CrwImage, Exiv2::EpsImage, Exiv2::RafImage, Exiv2::GifImage, Exiv2::TgaImage, Exiv2::Cr2Image, Exiv2::MatroskaVideo, Exiv2::TiffImage, Exiv2::Jp2Image, Exiv2::MrwImage, Exiv2::PsdImage, Exiv2::Rw2Image, Exiv2::PgfImage, Exiv2::PngImage, Exiv2::AsfVideo, Exiv2::OrfImage, Exiv2::RiffVideo, Exiv2::QuickTimeVideo, Exiv2::XmpSidecar, and Exiv2::WebPImage.
void Exiv2::Image::writeXmpFromPacket | ( | bool | flag | ) |
Determine the source when writing XMP.
Depending on the setting of this flag, writeMetadata() writes XMP from the buffered raw XMP packet or from parsed XMP data. The default is to write from parsed XMP data. The switch is also set by all functions to set and clear the buffered raw XMP packet and parsed XMP data, so using this function should usually not be necessary.
If Exiv2 was compiled without XMP support, the default for this flag is true and it will never be changed in order to preserve access to the raw XMP packet.
|
virtual |
Returns an XmpData instance containing currently buffered XMP data.
The contained XMP data may have been read from the image by a previous call to readMetadata() or added directly. The XMP data in the returned instance will be written to the image when writeMetadata() is called.
|
virtual |
Returns an XmpData instance containing currently buffered XMP data.
The contained XMP data may have been read from the image by a previous call to readMetadata() or added directly. The XMP data in the returned instance will be written to the image when writeMetadata() is called.