Exiv2::JpegBase Class Referenceabstract

Abstract helper base class to access JPEG images. More...

#include <jpgimage.hpp>

Inheritance diagram for Exiv2::JpegBase:

Protected Member Functions

Creators
 JpegBase (int type, BasicIo::AutoPtr io, bool create, const byte initData[], long dataSize)
 Constructor that can either open an existing image or create a new image from scratch. If a new image is to be created, any existing data is overwritten. More...
 

Static Protected Attributes

static const byte dht_
 JPEG DHT marker.
 
static const byte dqt_
 JPEG DQT marker.
 
static const byte dri_
 JPEG DRI marker.
 
static const byte sos_
 JPEG SOS marker.
 
static const byte eoi_
 JPEG EOI marker.
 
static const byte app0_
 JPEG APP0 marker.
 
static const byte app1_
 JPEG APP1 marker.
 
static const byte app2_
 JPEG APP2 marker.
 
static const byte app13_
 JPEG APP13 marker.
 
static const byte com_
 JPEG Comment marker.
 
static const byte sof0_
 JPEG Start-Of-Frame marker.
 
static const byte sof1_
 JPEG Start-Of-Frame marker.
 
static const byte sof2_
 JPEG Start-Of-Frame marker.
 
static const byte sof3_
 JPEG Start-Of-Frame marker.
 
static const byte sof5_
 JPEG Start-Of-Frame marker.
 
static const byte sof6_
 JPEG Start-Of-Frame marker.
 
static const byte sof7_
 JPEG Start-Of-Frame marker.
 
static const byte sof9_
 JPEG Start-Of-Frame marker.
 
static const byte sof10_
 JPEG Start-Of-Frame marker.
 
static const byte sof11_
 JPEG Start-Of-Frame marker.
 
static const byte sof13_
 JPEG Start-Of-Frame marker.
 
static const byte sof14_
 JPEG Start-Of-Frame marker.
 
static const byte sof15_
 JPEG Start-Of-Frame marker.
 
static const char exifId_ []
 Exif identifier.
 
static const char jfifId_ []
 JFIF identifier.
 
static const char xmpId_ []
 XMP packet identifier.
 
static const char iccId_ []
 ICC profile identifier.
 

Manipulators

void readMetadata ()
 Read all metadata supported by a specific image format from the image. Before this method is called, the image metadata will be cleared. More...
 
void writeMetadata ()
 Write metadata back to the image. More...
 
void printStructure (std::ostream &out, PrintStructureOption option, int depth)
 Print out the structure of image file. More...
 
virtual int writeHeader (BasicIo &oIo) const =0
 Writes the image header (aka signature) to the BasicIo instance. More...
 

Accessors

virtual bool isThisType (BasicIo &iIo, bool advance) const =0
 Determine if the content of the BasicIo instance is of the type supported by this class. More...
 

Additional Inherited Members

- Public Types inherited from Exiv2::Image
typedef std::auto_ptr< ImageAutoPtr
 Image auto_ptr type.
 
- Public Member Functions inherited from Exiv2::Image
void setTypeSupported (int imageType, uint16_t supportedMetadata)
 set type support for this image format
 
int imageType () const
 set type support for this image format
 
 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.
 
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 DataBuficcProfile ()
 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 ExifDataexifData ()
 Returns an ExifData instance containing currently buffered Exif data. More...
 
virtual IptcDataiptcData ()
 Returns an IptcData instance containing currently buffered IPTC data. More...
 
virtual XmpDataxmpData ()
 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 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)
 
uint32_t byteSwap (uint32_t value, bool bSwap)
 
uint16_t byteSwap (uint16_t value, bool bSwap)
 
uint16_t byteSwap2 (DataBuf &buf, size_t offset, bool bSwap)
 
uint32_t byteSwap4 (DataBuf &buf, size_t offset, bool bSwap)
 
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 ExifDataexifData () const
 Returns an ExifData instance containing currently buffered Exif data. More...
 
virtual const IptcDataiptcData () const
 Returns an IptcData instance containing currently buffered IPTC data. More...
 
virtual const XmpDataxmpData () 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 BasicIoio () 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 NativePreviewListnativePreviews () const
 Return list of native previews. This is meant to be used only by the PreviewManager.
 
- Protected Attributes inherited from Exiv2::Image
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
 

Detailed Description

Abstract helper base class to access JPEG images.

Constructor & Destructor Documentation

◆ JpegBase()

Exiv2::JpegBase::JpegBase ( int  type,
BasicIo::AutoPtr  io,
bool  create,
const byte  initData[],
long  dataSize 
)
protected

Constructor that can either open an existing image or create a new image from scratch. If a new image is to be created, any existing data is overwritten.

Parameters
typeImage type.
ioAn auto-pointer that owns a BasicIo instance used for reading and writing image metadata. Important: The constructor takes ownership of the passed in BasicIo instance through the auto-pointer. Callers should not continue to use the BasicIo instance after it is passed to this method. Use the Image::io() method to get a temporary reference.
createSpecifies if an existing image should be read (false) or if a new image should be created (true).
initDataData to initialize newly created images. Only used when create is true. Should contain data for the smallest valid image of the calling subclass.
dataSizeSize of initData in bytes.

Member Function Documentation

◆ isThisType()

virtual bool Exiv2::JpegBase::isThisType ( BasicIo iIo,
bool  advance 
) const
protectedpure virtual

Determine if the content of the BasicIo instance is of the type supported by this class.

The advance flag determines if the read position in the stream is moved (see below). This applies only if the type matches and the function returns true. If the type does not match, the stream position is not changed. However, if reading from the stream fails, the stream position is undefined. Consult the stream state to obtain more information in this case.

Parameters
iIoBasicIo instance to read from.
advanceFlag indicating whether the position of the io should be advanced by the number of characters read to analyse the data (true) or left at its original position (false). This applies only if the type matches.
Returns
true if the data matches the type of this class;
false if the data does not match

Implemented in Exiv2::ExvImage, and Exiv2::JpegImage.

◆ printStructure()

void Exiv2::JpegBase::printStructure ( std::ostream &  out,
PrintStructureOption  option,
int  depth 
)
virtual

Print out the structure of image file.

Exceptions
Errorif reading of the file fails or the image data is not valid (does not look like data of the specific image type).
Warning
This function is not thread safe and intended for exiv2 -pS for debugging.

Reimplemented from Exiv2::Image.

◆ readMetadata()

void Exiv2::JpegBase::readMetadata ( )
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.

Exceptions
Errorif opening or reading of the file fails or the image data is not valid (does not look like data of the specific image type).

Implements Exiv2::Image.

◆ writeHeader()

virtual int Exiv2::JpegBase::writeHeader ( BasicIo oIo) const
protectedpure virtual

Writes the image header (aka signature) to the BasicIo instance.

Parameters
oIoBasicIo instance that the header is written to.
Returns
0 if successful;
4 if the output file can not be written to

Implemented in Exiv2::ExvImage, and Exiv2::JpegImage.

◆ writeMetadata()

void Exiv2::JpegBase::writeMetadata ( )
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.

Exceptions
Errorif the operation fails

Implements Exiv2::Image.


The documentation for this class was generated from the following file: