Exiv2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Friends | List of all members
Exiv2::JpegImage Class Reference

Class to access JPEG images. More...

#include <jpgimage.hpp>

+ Inheritance diagram for Exiv2::JpegImage:
+ Collaboration diagram for Exiv2::JpegImage:

Public Member Functions

Creators
 JpegImage (BasicIo::AutoPtr io, bool create)
 Constructor that can either open an existing Jpeg image or create a new image from scratch. If a new image is to be created, any existing data is overwritten. Since the constructor can not return a result, callers should check the good() method after object construction to determine success or failure. More...
 
- Public Member Functions inherited from Exiv2::JpegBase
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...
 
- Public Member Functions inherited from Exiv2::Image
 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 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...
 
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 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 Member Functions

Manipulators
int writeHeader (BasicIo &oIo) const
 Writes a Jpeg header (aka signature) to the BasicIo instance. More...
 
- Protected Member Functions inherited from Exiv2::JpegBase
 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...
 

Friends

EXIV2API bool isJpegType (BasicIo &iIo, bool advance)
 Check if the file iIo is a JPEG image.
 

Accessors

std::string mimeType () const
 Return the MIME type of the image. More...
 
bool isThisType (BasicIo &iIo, bool advance) const
 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.
 
- 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.
 
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
 
- Static Protected Attributes inherited from Exiv2::JpegBase
static const byte sos_ = 0xda
 JPEG SOS marker.
 
static const byte eoi_ = 0xd9
 JPEG EOI marker.
 
static const byte app0_ = 0xe0
 JPEG APP0 marker.
 
static const byte app1_ = 0xe1
 JPEG APP1 marker.
 
static const byte app13_ = 0xed
 JPEG APP13 marker.
 
static const byte com_ = 0xfe
 JPEG Comment marker.
 
static const byte sof0_ = 0xc0
 JPEG Start-Of-Frame marker.
 
static const byte sof1_ = 0xc1
 JPEG Start-Of-Frame marker.
 
static const byte sof2_ = 0xc2
 JPEG Start-Of-Frame marker.
 
static const byte sof3_ = 0xc3
 JPEG Start-Of-Frame marker.
 
static const byte sof5_ = 0xc5
 JPEG Start-Of-Frame marker.
 
static const byte sof6_ = 0xc6
 JPEG Start-Of-Frame marker.
 
static const byte sof7_ = 0xc7
 JPEG Start-Of-Frame marker.
 
static const byte sof9_ = 0xc9
 JPEG Start-Of-Frame marker.
 
static const byte sof10_ = 0xca
 JPEG Start-Of-Frame marker.
 
static const byte sof11_ = 0xcb
 JPEG Start-Of-Frame marker.
 
static const byte sof13_ = 0xcd
 JPEG Start-Of-Frame marker.
 
static const byte sof14_ = 0xce
 JPEG Start-Of-Frame marker.
 
static const byte sof15_ = 0xcf
 JPEG Start-Of-Frame marker.
 
static const char exifId_ [] = "Exif\0\0"
 Exif identifier.
 
static const char jfifId_ [] = "JFIF\0"
 JFIF identifier.
 
static const char xmpId_ [] = "http://ns.adobe.com/xap/1.0/\0"
 XMP packet identifier.
 

Detailed Description

Class to access JPEG images.

Constructor & Destructor Documentation

Exiv2::JpegImage::JpegImage ( BasicIo::AutoPtr  io,
bool  create 
)

Constructor that can either open an existing Jpeg image or create a new image from scratch. If a new image is to be created, any existing data is overwritten. Since the constructor can not return a result, callers should check the good() method after object construction to determine success or failure.

Parameters
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 file should be created (true).

Member Function Documentation

bool Exiv2::JpegImage::isThisType ( BasicIo iIo,
bool  advance 
) const
protectedvirtual

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

Implements Exiv2::JpegBase.

References isJpegType.

std::string Exiv2::JpegImage::mimeType ( ) const
virtual

Return the MIME type of the image.

Note
For each supported image format, the library knows only one MIME type. This may not be the most specific MIME type for that format. In particular, several RAW formats are variants of the TIFF format with the same magic as TIFF itself. Class TiffImage handles most of them and thus they all have MIME type "image/tiff", although a more specific MIME type may exist (e.g., "image/x-nikon-nef").

Implements Exiv2::Image.

int Exiv2::JpegImage::writeHeader ( BasicIo oIo) const
protectedvirtual

Writes a Jpeg header (aka signature) to the BasicIo instance.

Parameters
oIoBasicIo instance that the header is written to.
Returns
0 if successful;
2 if the input image is invalid or can not be read;
4 if the temporary image can not be written to;
-3 other temporary errors

Implements Exiv2::JpegBase.

References Exiv2::BasicIo::error(), and Exiv2::BasicIo::write().


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