Exiv2::ExifParser Class Reference

Stateless parser class for Exif data. Images use this class to decode and encode binary Exif data. More...

#include <exif.hpp>

Static Public Member Functions

static ByteOrder decode (ExifData &exifData, const byte *pData, uint32_t size)
 Decode metadata from a buffer pData of length size with binary Exif data to the provided metadata container. More...
 
static WriteMethod encode (Blob &blob, const byte *pData, uint32_t size, ByteOrder byteOrder, const ExifData &exifData)
 Encode Exif metadata from the provided metadata to binary Exif format. More...
 
static void encode (Blob &blob, ByteOrder byteOrder, const ExifData &exifData)
 Encode metadata from the provided metadata to Exif format. More...
 

Detailed Description

Stateless parser class for Exif data. Images use this class to decode and encode binary Exif data.

Note
Encode is lossy and is not the inverse of decode.

Member Function Documentation

static ByteOrder Exiv2::ExifParser::decode ( ExifData exifData,
const byte pData,
uint32_t  size 
)
static

Decode metadata from a buffer pData of length size with binary Exif data to the provided metadata container.

   The buffer must start with a TIFF header. Return byte order
   in which the data is encoded.
Parameters
exifDataExif metadata container.
pDataPointer to the data buffer. Must point to data in binary Exif format; no checks are performed.
sizeLength of the data buffer
Returns
Byte order in which the data is encoded.
static WriteMethod Exiv2::ExifParser::encode ( Blob blob,
const byte pData,
uint32_t  size,
ByteOrder  byteOrder,
const ExifData exifData 
)
static

Encode Exif metadata from the provided metadata to binary Exif format.

The original binary Exif data in the memory block pData, size is parsed and updated in-place if possible ("non-intrusive" writing). If that is not possible (e.g., if new tags were added), the entire Exif structure is re-written to the blob ("intrusive" writing). The return value indicates which write method was used. If it is wmNonIntrusive, the original memory pData, size contains the result and blob is empty. If the return value is wmIntrusive, a new Exif structure was created and returned in blob. The memory block pData, size may be partly updated in this case and should not be used anymore.

Encode is a lossy operation. It attempts to fit the Exif data into a binary block suitable as the payload of a JPEG APP1 Exif segment, which can be at most 65527 bytes large. Encode omits IFD0 tags that are "not recorded" in compressed images according to the Exif 2.2 specification. It also doesn't write tags in groups which do not occur in JPEG images. If the resulting binary block is larger than allowed, it further deletes specific large preview tags, unknown tags larger than 4kB and known tags larger than 40kB. The operation succeeds even if the end result is still larger than the allowed size. Application should therefore always check the size of the blob.

Parameters
blobContainer for the binary Exif data if "intrusive" writing is necessary. Empty otherwise.
pDataPointer to the binary Exif data buffer. Must point to data in Exif format; no checks are performed. Will be modified if "non-intrusive" writing is possible.
sizeLength of the data buffer.
byteOrderByte order to use.
exifDataExif metadata container.
Returns
Write method used.
static void Exiv2::ExifParser::encode ( Blob blob,
ByteOrder  byteOrder,
const ExifData exifData 
)
inlinestatic

Encode metadata from the provided metadata to Exif format.

Encode Exif metadata from the ExifData container to binary Exif format in the blob, encoded in byteOrder.

This simpler encode method uses "intrusive" writing, i.e., it builds the binary representation of the metadata from scratch. It does not attempt "non-intrusive", i.e., in-place updating. It's better to use the other encode() method, if the metadata is already available in binary format, in order to allow for "non-intrusive" updating of the existing binary representation.

This is just an inline wrapper for ExifParser::encode(blob, 0, 0, byteOrder, exifData).

Parameters
blobContainer for the binary Exif data.
byteOrderByte order to use.
exifDataExif metadata container.

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