| Exiv2

Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
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, size_t size)
| Decode metadata from a buffer pData of length size with binary Exif data to the provided metadata container.
static WriteMethod | encode (Blob &blob, const byte *pData, size_t size, ByteOrder byteOrder, ExifData &exifData)
| Encode Exif metadata from the provided metadata to binary Exif format.
static void | encode (Blob &blob, ByteOrder byteOrder, ExifData &exifData)
| Encode metadata from the provided metadata to Exif format.

## 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

## ◆ decode()

ByteOrder Exiv2::ExifParser::decode | ( | ExifData & | exifData,
|  | const byte * | pData,
|  | size_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

  exifData | Exif metadata container.
  pData | Pointer to the data buffer. Must point to data in binary Exif format; no checks are performed.
  size | Length of the data buffer

Returns
  Byte order in which the data is encoded.

References Exiv2::TiffParser::decode(), Exiv2::IptcData::empty(), Exiv2::XmpData::empty(), and EXV_WARNING.

Referenced by Exiv2::JpegBase::readMetadata().

## ◆ encode() [1/2]

void Exiv2::ExifParser::encode | ( | Blob & | blob,
|  | ByteOrder | byteOrder,
|  | ExifData & | exifData )
| inline static

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

  blob | Container for the binary Exif data.
  byteOrder | Byte order to use.
  exifData | Exif metadata container.

References encode().

## ◆ encode() [2/2]

WriteMethod Exiv2::ExifParser::encode | ( | Blob & | blob,
|  | const byte * | pData,
|  | size_t | size,
|  | ByteOrder | byteOrder,
|  | 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

  blob | Container for the binary Exif data if "intrusive" writing is necessary. Empty otherwise.
  pData | Pointer 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.
  size | Length of the data buffer.
  byteOrder | Byte order to use.
  exifData | Exif metadata container.

Returns
  Write method used.

References Exiv2::append(), Exiv2::ExifData::begin(), Exiv2::Internal::TiffParserWorker::encode(), Exiv2::ExifData::end(), Exiv2::ExifData::erase(), EXV_WARNING, Exiv2::Internal::TiffMapping::findEncoder(), Exiv2::ExifData::findKey(), Exiv2::Internal::groupId(), Exiv2::MemIo::mmap(), Exiv2::Internal::Tag::root, and Exiv2::MemIo::size().

Referenced by encode().

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

- exif.hpp
- exif.cpp