 |
Exiv2
|
Go to the documentation of this file.
37 #include "exiv2lib_export.h"
61 static const char ps3Id_[];
62 static const char* irbId_[];
63 static const char bimId_[];
75 static bool isIrb(
const byte* pPsData,
85 static bool valid(
const byte* pPsData,
104 static int locateIrb(
const byte *pPsData,
108 uint32_t *
const sizeHdr,
109 uint32_t *
const sizeData);
113 static int locateIptcIrb(
const byte *pPsData,
116 uint32_t *
const sizeHdr,
117 uint32_t *
const sizeData);
121 static int locatePreviewIrb(
const byte *pPsData,
124 uint32_t *
const sizeHdr,
125 uint32_t *
const sizeData);
135 static DataBuf setIptcIrb(
const byte* pPsData,
149 void writeMetadata();
184 const byte initData[],
209 virtual bool isThisType(
BasicIo& iIo,
bool advance)
const =0;
220 virtual int writeHeader(
BasicIo& oIo)
const =0;
247 static const char exifId_[];
248 static const char jfifId_[];
249 static const char xmpId_[];
250 static const char iccId_[];
272 int initImage(
const byte initData[],
long dataSize);
280 void doWriteMetadata(
BasicIo& oIo);
293 int advanceToMarker()
const;
331 bool isThisType(
BasicIo& iIo,
bool advance)
const;
343 int writeHeader(
BasicIo& oIo)
const;
348 static const byte soi_;
349 static const byte blank_[];
392 bool isThisType(
BasicIo& iIo,
bool advance)
const;
396 int writeHeader(
BasicIo& oIo)
const;
401 static const char exiv2Id_[];
402 static const byte blank_[];
438 #endif // #ifndef JPGIMAGE_HPP_
static const byte com_
JPEG Comment marker.
Definition: jpgimage.hpp:233
Provides binary IO on blocks of memory by implementing the BasicIo interface. A copy-on-write impleme...
Definition: basicio.hpp:540
void clear()
Delete all Exifdatum instances resulting in an empty container. Note that this also removes thumbnail...
Definition: exif.cpp:587
static const uint16_t preview_
Photoshop preview marker
Definition: jpgimage.hpp:65
friend EXIV2API bool isJpegType(BasicIo &iIo, bool advance)
Check if the file iIo is a JPEG image.
Definition: jpgimage.cpp:1360
const int xmp
XMP sidecar files (see class XmpSidecar)
Definition: xmpsidecar.hpp:45
static const byte sof3_
JPEG Start-Of-Frame marker.
Definition: jpgimage.hpp:237
std::string xmpPacket_
XMP packet.
Definition: image.hpp:493
virtual bool isopen() const =0
Returns true if the IO source is open, otherwise false.
const int exv
EXV image type (see class ExvImage)
Definition: jpgimage.hpp:52
virtual int error() const =0
Returns 0 if the IO source is in a valid state, otherwise nonzero.
byte * pData_
Pointer to the buffer, 0 if none has been allocated.
Definition: types.hpp:269
IptcData iptcData_
IPTC data container.
Definition: image.hpp:489
static const byte dht_
JPEG DHT marker.
Definition: jpgimage.hpp:224
static const byte dqt_
JPEG DQT marker.
Definition: jpgimage.hpp:225
void writeMetadata()
Write metadata back to the image.
Definition: jpgimage.cpp:900
Utility class that closes a BasicIo instance upon destruction. Meant to be used as a stack variable i...
Definition: basicio.hpp:264
static int locateIrb(const byte *pPsData, long sizePsData, uint16_t psTag, const byte **record, uint32_t *const sizeHdr, uint32_t *const sizeData)
Locates the data for a Photoshop tag in a Photoshop formated memory buffer. Operates on raw data to s...
Definition: jpgimage.cpp:142
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.
std::vector< uint32_t > Uint32Vector
typedef for uint32_t vector
Definition: datasets.hpp:403
static const byte app2_
JPEG APP2 marker.
Definition: jpgimage.hpp:231
static const byte app13_
JPEG APP13 marker.
Definition: jpgimage.hpp:232
static const byte sof0_
JPEG Start-Of-Frame marker.
Definition: jpgimage.hpp:234
@ omitAllFormatting
Omit all formatting whitespace.
Definition: xmp_exiv2.hpp:285
std::string comment_
User comment.
Definition: image.hpp:492
static int decode(IptcData &iptcData, const byte *pData, uint32_t size)
Decode binary IPTC data in IPTC IIM4 format from a buffer pData of length size to the provided metada...
Definition: iptc.cpp:438
static const byte app0_
JPEG APP0 marker.
Definition: jpgimage.hpp:229
static int locateIptcIrb(const byte *pPsData, long sizePsData, const byte **record, uint32_t *const sizeHdr, uint32_t *const sizeData)
Forwards to locateIrb() with psTag = iptc_.
Definition: jpgimage.cpp:219
void printStructure(std::ostream &out, PrintStructureOption option, int depth)
Print out the structure of image file.
Definition: jpgimage.cpp:577
static const byte sof14_
JPEG Start-Of-Frame marker.
Definition: jpgimage.hpp:245
EXIV2API bool isExvType(BasicIo &iIo, bool advance)
Check if the file iIo is an EXV file.
Definition: jpgimage.cpp:1412
Slice< T > makeSlice(T &cont, size_t begin, size_t end)
Return a new slice with the given bounds.
Definition: slice.hpp:673
static const byte sof6_
JPEG Start-Of-Frame marker.
Definition: jpgimage.hpp:239
virtual std::string comment() const
Return a copy of the image comment. May be an empty string.
Definition: image.cpp:733
static const byte app1_
JPEG APP1 marker.
Definition: jpgimage.hpp:230
EXIV2API std::string strError()
Return a system error message and the error code (errno). See strerror(3).
Definition: futils.cpp:352
std::string mimeType() const
Return the MIME type of the image.
Definition: jpgimage.cpp:1382
static const char exifId_[]
Exif identifier.
Definition: jpgimage.hpp:247
ExifData exifData_
Exif data container.
Definition: image.hpp:488
static const byte sof5_
JPEG Start-Of-Frame marker.
Definition: jpgimage.hpp:238
binaryToStringHelper< T > binaryToString(const Slice< T > sl)
format binary data for display in Image::printStructure()
Definition: image_int.hpp:125
std::string string_from_unterminated(const char *data, size_t data_length)
Convert a (potentially not null terminated) array into a std::string.
Definition: helper_functions.cpp:33
void clear()
Delete all Iptcdatum instances resulting in an empty container.
Definition: iptc.hpp:218
virtual bool iccProfileDefined()
Erase iccProfile. the profile is not removed from the actual image until the writeMetadata() method i...
Definition: image.hpp:238
int pixelHeight_
image pixel height
Definition: image.hpp:495
static bool valid(const byte *pPsData, long sizePsData)
Validates all IRBs.
Definition: jpgimage.cpp:122
EXIV2API Image::AutoPtr newJpegInstance(BasicIo::AutoPtr io, bool create)
Create a new JpegImage instance and return an auto-pointer to it. Caller owns the returned object and...
Definition: jpgimage.cpp:1351
virtual void clearMetadata()
Erase all buffered metadata. Metadata is not removed from the actual image until the writeMetadata() ...
Definition: image.cpp:561
Uint32Vector::const_iterator Uint32Vector_i
typedef for Uint32Vector iterator
Definition: datasets.hpp:411
static const byte sof9_
JPEG Start-Of-Frame marker.
Definition: jpgimage.hpp:241
Port of D's enforce() to C++ & Exiv2.
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.
Definition: exif.cpp:644
EXIV2API Image::AutoPtr newExvInstance(BasicIo::AutoPtr io, bool create)
Create a new ExvImage instance and return an auto-pointer to it. Caller owns the returned object and ...
Definition: jpgimage.cpp:1404
std::string stringFormat(const char *format,...)
format a string in the pattern of sprintf .
Definition: image_int.cpp:32
void setByteOrder(ByteOrder byteOrder)
Set the byte order to encode the Exif metadata in.
Definition: image.cpp:698
EXIV2API void hexdump(std::ostream &os, const byte *buf, long len, long offset=0)
Print len bytes from buf in hex and ASCII format to the given stream, prefixed with the position in t...
Definition: types.cpp:518
ByteOrder byteOrder() const
Return the byte order in which the Exif metadata of the image is encoded. Initially,...
Definition: image.cpp:703
bool isThisType(BasicIo &iIo, bool advance) const
Determine if the content of the BasicIo instance is of the type supported by this class.
Definition: jpgimage.cpp:1346
static void printStructure(std::ostream &out, const Slice< byte * > &bytes, uint32_t depth)
dump iptc formatted binary data (used by printStructure kpsRecursive)
Definition: iptc.cpp:352
EXIV2API void append(Exiv2::Blob &blob, const byte *buf, uint32_t len)
Append len bytes pointed to by buf to blob.
Definition: image.cpp:1004
int pixelWidth_
image pixel width
Definition: image.hpp:494
void enforce(bool condition, const T &arg1)
Ensure that condition is true, otherwise throw an exception of the type exception_t.
Definition: enforce.hpp:43
static const byte sof1_
JPEG Start-Of-Frame marker.
Definition: jpgimage.hpp:235
int writeHeader(BasicIo &oIo) const
Writes the image header (aka signature) to the BasicIo instance.
Definition: jpgimage.cpp:1387
void printTiffStructure(BasicIo &io, std::ostream &out, PrintStructureOption option, int depth, size_t offset=0)
Print out the structure of image file.
Definition: image.cpp:543
A collection of helper functions.
bool isThisType(BasicIo &iIo, bool advance) const
Determine if the content of the BasicIo instance is of the type supported by this class.
Definition: jpgimage.cpp:1399
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition: types.hpp:204
EXIV2API long us2Data(byte *buf, uint16_t s, ByteOrder byteOrder)
Convert an unsigned short to data, write the data to the buffer, return number of bytes written.
Definition: types.cpp:395
int writeHeader(BasicIo &oIo) const
Writes a Jpeg header (aka signature) to the BasicIo instance.
Definition: jpgimage.cpp:1335
@ useCompactFormat
Use a compact form of RDF.
Definition: xmp_exiv2.hpp:281
std::string mimeType() const
Return the MIME type of the image.
Definition: jpgimage.cpp:1330
virtual int putb(byte data)=0
Write one byte to the IO source. Current IO position is advanced by one byte.
static const byte sof2_
JPEG Start-Of-Frame marker.
Definition: jpgimage.hpp:236
long count() const
Get the number of metadata entries.
Definition: xmp.cpp:370
long size_
The current size of the buffer.
Definition: types.hpp:271
static int encode(std::string &xmpPacket, const XmpData &xmpData, uint16_t formatFlags=useCompactFormat, uint32_t padding=0)
Encode (serialize) XMP metadata from xmpData into a string xmpPacket. The XMP packet returned in the ...
Definition: xmp.cpp:836
virtual bool eof() const =0
Returns true if the IO position has reached the end, otherwise false.
const T * find(T(&src)[N], const K &key)
Find an element that matches key in the array src.
Definition: types.hpp:508
static const char iccId_[]
ICC profile identifier.
Definition: jpgimage.hpp:250
virtual DataBuf read(long rcount)=0
Read data from the IO source. Reading starts at the current IO position and the position is advanced ...
long count() const
Get the number of metadata entries.
Definition: exif.hpp:514
Class to access JPEG images.
Definition: jpgimage.hpp:301
static const byte eoi_
JPEG EOI marker.
Definition: jpgimage.hpp:228
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
static const char jfifId_[]
JFIF identifier.
Definition: jpgimage.hpp:248
EXIV2API long ul2Data(byte *buf, uint32_t l, ByteOrder byteOrder)
Convert an unsigned long to data, write the data to the buffer, return number of bytes written.
Definition: types.cpp:408
Abstract helper base class to access JPEG images.
Definition: jpgimage.hpp:144
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 con...
Definition: exif.cpp:612
void readMetadata()
Read all metadata supported by a specific image format from the image. Before this method is called,...
Definition: jpgimage.cpp:343
static const byte sof13_
JPEG Start-Of-Frame marker.
Definition: jpgimage.hpp:244
Overflow checks for integers.
#define EXV_WARNING
Shorthand for a temp warning log message object and return its ostringstream.
Definition: error.hpp:148
virtual long write(const byte *data, long wcount)=0
Write data to the IO source. Current IO position is advanced by the number of bytes written.
Helper class to access Exiv2 files.
Definition: jpgimage.hpp:362
const int jpeg
JPEG image type (see class JpegImage)
Definition: jpgimage.hpp:51
EXIV2API uint16_t getUShort(const byte *buf, ByteOrder byteOrder)
Read a 2 byte unsigned short value from the data buffer.
Definition: types.cpp:278
BasicIo::AutoPtr io_
Image data IO pointer.
Definition: image.hpp:487
ByteOrder
Type to express the byte order (little or big endian)
Definition: types.hpp:113
DataBuf iccProfile_
ICC buffer (binary data)
Definition: image.hpp:491
bool usePacket() const
are we to use the packet?
Definition: xmp_exiv2.hpp:252
static const char * irbId_[]
Photoshop IRB markers
Definition: jpgimage.hpp:62
std::auto_ptr< Image > AutoPtr
Image auto_ptr type.
Definition: image.hpp:84
virtual std::string & xmpPacket()
Return a modifiable reference to the raw XMP packet.
Definition: image.cpp:586
static const char ps3Id_[]
Photoshop marker
Definition: jpgimage.hpp:61
static const byte sof11_
JPEG Start-Of-Frame marker.
Definition: jpgimage.hpp:243
static const byte sof15_
JPEG Start-Of-Frame marker.
Definition: jpgimage.hpp:246
T add(T summand_1, T summand_2)
Safe addition, throws an exception on overflow.
Definition: safe_op.hpp:295
std::auto_ptr< BasicIo > AutoPtr
BasicIo auto_ptr type.
Definition: basicio.hpp:58
bool writeXmpFromPacket() const
Return the flag indicating the source when writing XMP metadata.
Definition: image.cpp:748
BasicError< char > Error
Error class used for exceptions (std::string based)
Definition: error.hpp:324
virtual int writeHeader(BasicIo &oIo) const =0
Writes the image header (aka signature) to the BasicIo instance.
EXIV2API bool isJpegType(BasicIo &iIo, bool advance)
Check if the file iIo is a JPEG image.
Definition: jpgimage.cpp:1360
A container for IPTC data. This is a top-level class of the Exiv2 library.
Definition: iptc.hpp:173
static const byte dri_
JPEG DRI marker.
Definition: jpgimage.hpp:226
static DataBuf encode(const IptcData &iptcData)
Encode the IPTC datasets from iptcData to a binary representation in IPTC IIM4 format.
Definition: iptc.cpp:515
@ string
IPTC string type.
Definition: types.hpp:147
PrintStructureOption
Options for printStructure.
Definition: image.hpp:67
static const char xmpId_[]
XMP packet identifier.
Definition: jpgimage.hpp:249
static bool isIrb(const byte *pPsData, long sizePsData)
Checks an IRB.
Definition: jpgimage.cpp:111
#define EXV_ERROR
Shorthand for a temp error log message object and return its ostringstream.
Definition: error.hpp:150
virtual int seek(long offset, Position pos)=0
Move the current IO position.
static const uint16_t iptc_
Photoshop IPTC marker
Definition: jpgimage.hpp:64
static DataBuf setIptcIrb(const byte *pPsData, long sizePsData, const IptcData &iptcData)
Set the new IPTC IRB, keeps existing IRBs but removes the IPTC block if there is no new IPTC data to ...
Definition: jpgimage.cpp:239
static const byte sof10_
JPEG Start-Of-Frame marker.
Definition: jpgimage.hpp:242
static const byte sof7_
JPEG Start-Of-Frame marker.
Definition: jpgimage.hpp:240
Helper class, has methods to deal with Photoshop "Information Resource Blocks" (IRBs).
Definition: jpgimage.hpp:59
An interface for simple binary IO.
Definition: basicio.hpp:55
long count() const
Get the number of metadata entries.
Definition: iptc.hpp:260
XmpData xmpData_
XMP data container.
Definition: image.hpp:490
virtual XmpData & xmpData()
Returns an XmpData instance containing currently buffered XMP data.
Definition: image.cpp:581
Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2...
Definition: image.hpp:81
virtual void setIccProfile(DataBuf &iccProfile, bool bTestValid=true)
Set the image iccProfile. The new profile is not written to the image until the writeMetadata() metho...
Definition: image.cpp:683
WriteMethod
Type to indicate write method used by TIFF parsers.
Definition: types.hpp:116
static int locatePreviewIrb(const byte *pPsData, long sizePsData, const byte **record, uint32_t *const sizeHdr, uint32_t *const sizeData)
Forwards to locatePreviewIrb() with psTag = preview_.
Definition: jpgimage.cpp:229
Basic file utility functions required by Exiv2.
static int decode(XmpData &xmpData, const std::string &xmpPacket)
Decode XMP metadata from an XMP packet xmpPacket into xmpData. The format of the XMP packet must foll...
Definition: xmp.cpp:723
static const byte sos_
JPEG SOS marker.
Definition: jpgimage.hpp:227
EXIV2API uint32_t getULong(const byte *buf, ByteOrder byteOrder)
Read a 4 byte unsigned long value from the data buffer.
Definition: types.cpp:283
friend EXIV2API bool isExvType(BasicIo &iIo, bool advance)
Check if the file iIo is an EXV file.
Definition: jpgimage.cpp:1412
Error class for exceptions, log message class.
static const char bimId_[]
Photoshop IRB marker (deprecated)
Definition: jpgimage.hpp:63
std::vector< byte > Blob
Container for binary data.
Definition: types.hpp:162
Class JpegImage to access JPEG images.