1
// ***************************************************************** -*- C++ -*-
3
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
5
* This program is part of the Exiv2 distribution.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 2
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
@brief Encoding and decoding of Exif data
25
@author Andreas Huggel (ahu)
26
<a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a>
27
@date 09-Jan-04, ahu: created
32
// *****************************************************************************
33
// included header files
34
#include "metadatum.hpp"
41
// + standard includes
46
// *****************************************************************************
47
// namespace extensions
49
@brief Provides classes and functions to encode and decode Exif and Iptc data.
50
This namespace corresponds to the <b>libexiv2</b> library.
55
// *****************************************************************************
61
// *****************************************************************************
65
@brief Information related to one Exif tag. An Exif metadatum consists of
66
an ExifKey and a Value and provides methods to manipulate these.
68
class Exifdatum : public Metadatum {
69
friend std::ostream& operator<<(std::ostream&, const Exifdatum&);
70
template<typename T> friend Exifdatum& setValue(Exifdatum&, const T&);
75
@brief Constructor for new tags created by an application. The
76
%Exifdatum is created from a \em key / value pair. %Exifdatum copies
77
(clones) the \em key and value if one is provided. Alternatively,
78
a program can create an 'empty' %Exifdatum with only a key
79
and set the value using setValue().
82
@param pValue Pointer to an %Exifdatum value.
83
@throw Error if the key cannot be parsed and converted.
85
explicit Exifdatum(const ExifKey& key, const Value* pValue =0);
86
//! Constructor to build an %Exifdatum from an IFD entry.
87
Exifdatum(const Entry& e, ByteOrder byteOrder);
89
Exifdatum(const Exifdatum& rhs);
94
//! @name Manipulators
96
//! Assignment operator
97
Exifdatum& operator=(const Exifdatum& rhs);
99
@brief Assign \em value to the %Exifdatum. The type of the new Value
100
is set to UShortValue.
102
Exifdatum& operator=(const uint16_t& value);
104
@brief Assign \em value to the %Exifdatum. The type of the new Value
105
is set to ULongValue.
107
Exifdatum& operator=(const uint32_t& value);
109
@brief Assign \em value to the %Exifdatum. The type of the new Value
110
is set to URationalValue.
112
Exifdatum& operator=(const URational& value);
114
@brief Assign \em value to the %Exifdatum. The type of the new Value
115
is set to ShortValue.
117
Exifdatum& operator=(const int16_t& value);
119
@brief Assign \em value to the %Exifdatum. The type of the new Value
122
Exifdatum& operator=(const int32_t& value);
124
@brief Assign \em value to the %Exifdatum. The type of the new Value
125
is set to RationalValue.
127
Exifdatum& operator=(const Rational& value);
129
@brief Assign \em value to the %Exifdatum.
130
Calls setValue(const std::string&).
132
Exifdatum& operator=(const std::string& value);
134
@brief Assign \em value to the %Exifdatum.
135
Calls setValue(const Value*).
137
Exifdatum& operator=(const Value& value);
139
@brief Set the value. This method copies (clones) the value pointed
142
void setValue(const Value* pValue);
144
@brief Set the value to the string \em value. Uses Value::read(const
145
std::string&). If the %Exifdatum does not have a Value yet,
146
then a %Value of the correct type for this %Exifdatum is
147
created. An AsciiValue is created for unknown tags.
149
void setValue(const std::string& value);
151
@brief Set the value from an IFD entry.
153
void setValue(const Entry& e, ByteOrder byteOrder);
155
@brief Set the data area by copying (cloning) the buffer pointed to
158
Values may have a data area, which can contain additional
159
information besides the actual value. This method is used to set such
162
@param buf Pointer to the source data area
163
@param len Size of the data area
164
@return Return -1 if the %Exifdatum does not have a value yet or the
165
value has no data area, else 0.
167
int setDataArea(const byte* buf, long len)
168
{ return value_.get() == 0 ? -1 : value_->setDataArea(buf, len); }
173
//! Return the key of the %Exifdatum.
174
std::string key() const
175
{ return key_.get() == 0 ? "" : key_->key(); }
176
//! Return the name of the group (the second part of the key)
177
std::string groupName() const
178
{ return key_.get() == 0 ? "" : key_->groupName(); }
179
//! Return the name of the tag (which is also the third part of the key)
180
std::string tagName() const
181
{ return key_.get() == 0 ? "" : key_->tagName(); }
184
{ return key_.get() == 0 ? 0xffff : key_->tag(); }
185
//! Return the IFD id
187
{ return key_.get() == 0 ? ifdIdNotSet : key_->ifdId(); }
188
//! Return the name of the IFD
189
const char* ifdName() const
190
{ return key_.get() == 0 ? "" : key_->ifdName(); }
191
//! Return the related image item (deprecated)
192
std::string ifdItem() const
193
{ return key_.get() == 0 ? "" : key_->ifdItem(); }
194
//! Return the index (unique id of this key within the original IFD)
196
{ return key_.get() == 0 ? 0 : key_->idx(); }
198
@brief Write value to a data buffer and return the number
201
The user must ensure that the buffer has enough memory. Otherwise
202
the call results in undefined behaviour.
204
@param buf Data buffer to write to.
205
@param byteOrder Applicable byte order (little or big endian).
206
@return Number of characters written.
208
long copy(byte* buf, ByteOrder byteOrder) const
209
{ return value_.get() == 0 ? 0 : value_->copy(buf, byteOrder); }
210
//! Return the type id of the value
211
TypeId typeId() const
212
{ return value_.get() == 0 ? invalidTypeId : value_->typeId(); }
213
//! Return the name of the type
214
const char* typeName() const
215
{ return TypeInfo::typeName(typeId()); }
216
//! Return the size in bytes of one component of this type
217
long typeSize() const
218
{ return TypeInfo::typeSize(typeId()); }
219
//! Return the number of components in the value
221
{ return value_.get() == 0 ? 0 : value_->count(); }
222
//! Return the size of the value in bytes
224
{ return value_.get() == 0 ? 0 : value_->size(); }
225
//! Return the value as a string.
226
std::string toString() const
227
{ return value_.get() == 0 ? "" : value_->toString(); }
229
@brief Return the <EM>n</EM>-th component of the value converted to
230
long. The return value is -1 if the value of the Exifdatum is
231
not set and the behaviour of the method is undefined if there
232
is no n-th component.
234
long toLong(long n =0) const
235
{ return value_.get() == 0 ? -1 : value_->toLong(n); }
237
@brief Return the <EM>n</EM>-th component of the value converted to
238
float. The return value is -1 if the value of the Exifdatum is
239
not set and the behaviour of the method is undefined if there
240
is no n-th component.
242
float toFloat(long n =0) const
243
{ return value_.get() == 0 ? -1 : value_->toFloat(n); }
245
@brief Return the <EM>n</EM>-th component of the value converted to
246
Rational. The return value is -1/1 if the value of the
247
Exifdatum is not set and the behaviour of the method is
248
undefined if there is no n-th component.
250
Rational toRational(long n =0) const
251
{ return value_.get() == 0 ? Rational(-1, 1) : value_->toRational(n); }
253
@brief Return an auto-pointer to a copy (clone) of the value. The
254
caller owns this copy and the auto-pointer ensures that it will
257
This method is provided for users who need full control over the
258
value. A caller may, e.g., downcast the pointer to the appropriate
259
subclass of Value to make use of the interface of the subclass to set
260
or modify its contents.
262
@return An auto-pointer to a copy (clone) of the value, 0 if the value
265
Value::AutoPtr getValue() const
266
{ return value_.get() == 0 ? Value::AutoPtr(0) : value_->clone(); }
268
@brief Return a constant reference to the value.
270
This method is provided mostly for convenient and versatile output of
271
the value which can (to some extent) be formatted through standard
272
stream manipulators. Do not attempt to write to the value through
277
ExifData::const_iterator i = exifData.findKey(key);
278
if (i != exifData.end()) {
279
std::cout << i->key() << " " << std::hex << i->value() << "\n";
283
@return A constant reference to the value.
284
@throw Error if the value is not set.
286
const Value& value() const;
287
//! Return the size of the data area.
288
long sizeDataArea() const
289
{ return value_.get() == 0 ? 0 : value_->sizeDataArea(); }
291
@brief Return a copy of the data area of the value. The caller owns
292
this copy and %DataBuf ensures that it will be deleted.
294
Values may have a data area, which can contain additional
295
information besides the actual value. This method is used to access
298
@return A %DataBuf containing a copy of the data area or an empty
299
%DataBuf if the value does not have a data area assigned or the
302
DataBuf dataArea() const
303
{ return value_.get() == 0 ? DataBuf(0, 0) : value_->dataArea(); }
309
ExifKey::AutoPtr key_; //!< Key
310
Value::AutoPtr value_; //!< Value
312
}; // class Exifdatum
315
@brief Output operator for Exifdatum types, prints the interpreted
318
std::ostream& operator<<(std::ostream& os, const Exifdatum& md);
321
@brief Set the value of \em exifDatum to \em value. If the object already
322
has a value, it is replaced. Otherwise a new ValueType\<T\> value
323
is created and set to \em value.
325
This is a helper function, called from Exifdatum members. It is meant to
326
be used with T = (u)int16_t, (u)int32_t or (U)Rational. Do not use directly.
329
Exifdatum& setValue(Exifdatum& exifDatum, const T& value);
332
@brief Exif %Thumbnail image. This abstract base class provides the
333
interface for the thumbnail image that is optionally embedded in
334
the Exif data. This class is used internally by ExifData, it is
335
probably not useful for a client as a standalone class. Instead,
336
use an instance of ExifData to access the Exif thumbnail image.
340
//! Shortcut for a %Thumbnail auto pointer.
341
typedef std::auto_ptr<Thumbnail> AutoPtr;
345
//! Virtual destructor
346
virtual ~Thumbnail() {}
352
@brief Set the image data as data area of the appropriate Exif
353
metadatum. Read the thumbnail image data from data buffer
354
\em buf. Return 0 if successful.
356
@param exifData Exif data corresponding to the data buffer.
357
@param pIfd1 Corresponding raw IFD1.
358
@param buf Data buffer containing the thumbnail data. The buffer must
359
start with the TIFF header.
360
@param len Number of bytes in the data buffer.
361
@return 0 if successful;<BR>
362
1 in case of inconsistent thumbnail Exif data; or<BR>
363
2 if the data area is outside of the data buffer
365
virtual int setDataArea(ExifData& exifData,
370
@brief Return the thumbnail image in a %DataBuf. The caller owns the
371
data buffer and %DataBuf ensures that it will be deleted.
373
virtual DataBuf copy(const ExifData& exifData) const =0;
375
@brief Return a short string for the format of the thumbnail
378
virtual const char* format() const =0;
380
@brief Return the file extension for the format of the thumbnail
383
virtual const char* extension() const =0;
387
//! @name Manipulators
390
@brief Assignment operator. Protected so that it can only be used
391
by subclasses but not directly.
393
Thumbnail& operator=(const Thumbnail& rhs);
396
}; // class Thumbnail
398
//! Exif thumbnail image in TIFF format
399
class TiffThumbnail : public Thumbnail {
401
//! Shortcut for a %TiffThumbnail auto pointer.
402
typedef std::auto_ptr<TiffThumbnail> AutoPtr;
404
//! @name Manipulators
406
//! Assignment operator.
407
TiffThumbnail& operator=(const TiffThumbnail& rhs) { return *this; }
412
int setDataArea(ExifData& exifData,
416
DataBuf copy(const ExifData& exifData) const;
417
const char* format() const;
418
const char* extension() const;
421
}; // class TiffThumbnail
423
//! Exif thumbnail image in JPEG format
424
class JpegThumbnail : public Thumbnail {
426
//! Shortcut for a %JpegThumbnail auto pointer.
427
typedef std::auto_ptr<JpegThumbnail> AutoPtr;
429
//! @name Manipulators
431
//! Assignment operator.
432
JpegThumbnail& operator=(const JpegThumbnail& rhs) { return *this; }
437
int setDataArea(ExifData& exifData,
441
DataBuf copy(const ExifData& exifData) const;
442
const char* format() const;
443
const char* extension() const;
446
}; // class JpegThumbnail
448
//! Container type to hold all metadata
449
typedef std::vector<Exifdatum> ExifMetadata;
451
//! Unary predicate that matches a Exifdatum with a given ifd id and idx
452
class FindMetadatumByIfdIdIdx {
454
//! Constructor, initializes the object with the ifd id and idx to look for
455
FindMetadatumByIfdIdIdx(IfdId ifdId, int idx)
456
: ifdId_(ifdId), idx_(idx) {}
458
@brief Returns true if the ifd id and idx of the argument
459
\em exifdatum is equal to that of the object.
461
bool operator()(const Exifdatum& exifdatum) const
462
{ return ifdId_ == exifdatum.ifdId() && idx_ == exifdatum.idx(); }
468
}; // class FindMetadatumByIfdIdIdx
471
@brief A container for Exif data. This is a top-level class of the %Exiv2
472
library. The container holds Exifdatum objects.
474
Provide high-level access to the Exif data of an image:
475
- read Exif information from JPEG files
476
- access metadata through keys and standard C++ iterators
477
- add, modify and delete metadata
478
- write Exif data to JPEG files
479
- extract Exif metadata to files, insert from these files
480
- extract and delete Exif thumbnail (JPEG and TIFF thumbnails)
484
//! ExifMetadata iterator type
485
typedef ExifMetadata::iterator iterator;
486
//! ExifMetadata const iterator type
487
typedef ExifMetadata::const_iterator const_iterator;
491
//! Default constructor
493
//! Copy constructor (Todo: copy image data also)
494
ExifData(const ExifData& rhs);
499
//! @name Manipulators
501
//! Assignment operator (Todo: assign image data also)
502
ExifData& operator=(const ExifData& rhs);
504
@brief Load the Exif data from a byte buffer. The data buffer
505
must start with the TIFF header.
506
@param buf Pointer to the data buffer to read from
507
@param len Number of bytes in the data buffer
508
@return 0 if successful.
510
int load(const byte* buf, long len);
512
@brief Write the Exif data to a data buffer, which is returned. The
513
caller owns this copy and %DataBuf ensures that it will be
514
deleted. The copied data starts with the TIFF header.
516
Tries to update the original data buffer and write it back with
517
minimal changes, in a 'non-intrusive' fashion, if possible. In this
518
case, tag data that ExifData does not understand stand a good chance
519
to remain valid. (In particular, if the Exif data contains a
520
Makernote in IFD format, the offsets in its IFD will remain valid.)
522
If 'non-intrusive' writing is not possible, the Exif data will be
523
re-built from scratch, in which case the absolute position of the
524
metadata entries within the data buffer may (and in most cases will)
525
be different from their original position. Furthermore, in this case,
526
the Exif data is updated with the metadata from the actual thumbnail
527
image (overriding existing metadata).
529
@return A %DataBuf containing the Exif data.
533
@brief Returns a reference to the %Exifdatum that is associated with a
534
particular \em key. If %ExifData does not already contain such
535
an %Exifdatum, operator[] adds object \em Exifdatum(key).
537
@note Since operator[] might insert a new element, it can't be a const
540
Exifdatum& operator[](const std::string& key);
542
@brief Add all (IFD) entries in the range from iterator position begin
543
to iterator position end to the Exif metadata. No duplicate
544
checks are performed, i.e., it is possible to add multiple
545
metadata with the same key.
547
void add(Entries::const_iterator begin,
548
Entries::const_iterator end,
549
ByteOrder byteOrder);
551
@brief Add an Exifdatum from the supplied key and value pair. This
552
method copies (clones) key and value. No duplicate checks are
553
performed, i.e., it is possible to add multiple metadata with
556
void add(const ExifKey& key, const Value* pValue);
558
@brief Add a copy of the \em exifdatum to the Exif metadata. No
559
duplicate checks are performed, i.e., it is possible to add
560
multiple metadata with the same key.
562
@throw Error if the makernote cannot be created
564
void add(const Exifdatum& exifdatum);
566
@brief Delete the Exifdatum at iterator position \em pos, return the
567
position of the next exifdatum. Note that iterators into
568
the metadata, including \em pos, are potentially invalidated
571
iterator erase(iterator pos);
573
@brief Delete all Exifdatum instances resulting in an empty container.
574
Note that this also removes thumbnails.
576
void clear() { eraseThumbnail(); exifMetadata_.clear(); }
577
//! Sort metadata by key
579
//! Sort metadata by tag
581
//! Begin of the metadata
582
iterator begin() { return exifMetadata_.begin(); }
583
//! End of the metadata
584
iterator end() { return exifMetadata_.end(); }
586
@brief Find a Exifdatum with the given \em key, return an iterator to
587
it. If multiple metadata with the same key exist, it is
588
undefined which of the matching metadata is found.
590
iterator findKey(const ExifKey& key);
592
@brief Find the Exifdatum with the given \em ifdId and \em idx,
593
return an iterator to it.
595
This method can be used to uniquely identify an exifdatum that was
596
created from an IFD or from the makernote (with idx greater than
597
0). Metadata created by an application (not read from an IFD or a
598
makernote) all have their idx field set to 0, i.e., they cannot be
599
uniquely identified with this method. If multiple metadata with the
600
same key exist, it is undefined which of the matching metadata is
603
iterator findIfdIdIdx(IfdId ifdId, int idx);
605
@brief Set the Exif thumbnail to the Jpeg image \em path. Set
606
XResolution, YResolution and ResolutionUnit to \em xres,
607
\em yres and \em unit, respectively.
609
This results in the minimal thumbnail tags being set for a Jpeg
610
thumbnail, as mandated by the Exif standard.
612
@throw Error if reading the file fails.
614
@note No checks on the file format or size are performed.
615
@note Additional existing Exif thumbnail tags are not modified.
616
@note The Jpeg image inserted as thumbnail image should not
617
itself contain Exif data (or other metadata), as existing
618
applications may have problems with that. (The preview
619
application that comes with OS X for one.) - David Harvey.
621
void setJpegThumbnail(const std::string& path,
622
URational xres, URational yres, uint16_t unit);
624
@brief Set the Exif thumbnail to the Jpeg image pointed to by \em buf,
625
and size \em size. Set XResolution, YResolution and
626
ResolutionUnit to \em xres, \em yres and \em unit, respectively.
628
This results in the minimal thumbnail tags being set for a Jpeg
629
thumbnail, as mandated by the Exif standard.
631
@throw Error if reading the file fails.
633
@note No checks on the image format or size are performed.
634
@note Additional existing Exif thumbnail tags are not modified.
635
@note The Jpeg image inserted as thumbnail image should not
636
itself contain Exif data (or other metadata), as existing
637
applications may have problems with that. (The preview
638
application that comes with OS X for one.) - David Harvey.
640
void setJpegThumbnail(const byte* buf, long size,
641
URational xres, URational yres, uint16_t unit);
643
@brief Set the Exif thumbnail to the Jpeg image \em path.
645
This sets only the Compression, JPEGInterchangeFormat and
646
JPEGInterchangeFormatLength tags, which is not all the thumbnail
647
Exif information mandatory according to the Exif standard. (But it's
648
enough to work with the thumbnail.)
650
@throw Error if reading the file fails.
652
@note No checks on the file format or size are performed.
653
@note Additional existing Exif thumbnail tags are not modified.
655
void setJpegThumbnail(const std::string& path);
657
@brief Set the Exif thumbnail to the Jpeg image pointed to by \em buf,
660
This sets only the Compression, JPEGInterchangeFormat and
661
JPEGInterchangeFormatLength tags, which is not all the thumbnail
662
Exif information mandatory according to the Exif standard. (But it's
663
enough to work with the thumbnail.)
665
@note No checks on the image format or size are performed.
666
@note Additional existing Exif thumbnail tags are not modified.
668
void setJpegThumbnail(const byte* buf, long size);
670
@brief Delete the thumbnail from the Exif data. Removes all
671
Exif.%Thumbnail.*, i.e., IFD1 metadata.
673
@return The number of bytes of thumbnail data erased from the original
674
Exif data. Note that the original image size may differ from
675
the size of the image after deleting the thumbnail by more
676
than this number. This is the case if the Exif data contains
677
extra bytes (often at the end of the Exif block) or gaps and
678
the thumbnail is not located at the end of the Exif block so
679
that non-intrusive writing of a truncated Exif block is not
680
possible. Instead it is in this case necessary to write the
681
Exif data, without the thumbnail, from the metadata and all
682
extra bytes and gaps are lost, resulting in a smaller image.
684
long eraseThumbnail();
689
//! Begin of the metadata
690
const_iterator begin() const { return exifMetadata_.begin(); }
691
//! End of the metadata
692
const_iterator end() const { return exifMetadata_.end(); }
694
@brief Find an exifdatum with the given \em key, return a const
695
iterator to it. If multiple metadata with the same key exist,
696
it is undefined which of the matching metadata is found.
698
const_iterator findKey(const ExifKey& key) const;
700
@brief Find the exifdatum with the given \em ifdId and \em idx,
701
return an iterator to it.
703
This method can be used to uniquely identify a Exifdatum that was
704
created from an IFD or from the makernote (with idx greater than
705
0). Metadata created by an application (not read from an IFD or a
706
makernote) all have their idx field set to 0, i.e., they cannot be
707
uniquely identified with this method. If multiple metadata with the
708
same key exist, it is undefined which of the matching metadata is
711
const_iterator findIfdIdIdx(IfdId ifdId, int idx) const;
712
//! Return true if there is no Exif metadata
713
bool empty() const { return count() == 0; }
714
//! Get the number of metadata entries
715
long count() const { return static_cast<long>(exifMetadata_.size()); }
717
@brief Returns the byte order. Default is little endian.
719
ByteOrder byteOrder() const;
721
@brief Write the thumbnail image to a file. A filename extension
722
is appended to \em path according to the image type of the
723
thumbnail, so \em path should not include an extension.
724
This will overwrite an existing file of the same name.
726
@param path Path of the filename without image type extension
728
@throw Error if writing to the file fails.
730
@return 0 if successful;<BR>
731
8 if the Exif data does not contain a thumbnail.
733
int writeThumbnail(const std::string& path) const;
735
@brief Return the thumbnail image in a %DataBuf. The caller owns the
736
data buffer and %DataBuf ensures that it will be deleted.
738
DataBuf copyThumbnail() const;
740
@brief Return a short string describing the format of the Exif
741
thumbnail ("TIFF", "JPEG").
743
const char* thumbnailFormat() const;
745
@brief Return the file extension for the Exif thumbnail depending
746
on the format (".tif", ".jpg").
748
const char* thumbnailExtension() const;
750
@brief Return a thumbnail object of the correct type, corresponding to
751
the current Exif data. Caller owns this object and the auto
752
pointer ensures that it will be deleted.
754
Thumbnail::AutoPtr getThumbnail() const;
758
//! @name Manipulators
761
@brief Read the thumbnail from the data buffer. Assigns the thumbnail
762
data area with the appropriate Exif tags. Return 0 if successful,
763
i.e., if there is a thumbnail.
767
@brief Check if the metadata changed and update the internal IFDs and
768
the MakerNote if the changes are compatible with the existing
769
data (non-intrusive write support).
771
@return True if only compatible changes were detected in the metadata
772
and the internal IFDs and MakerNote (and thus the data buffer)
773
were updated successfully. Return false, if non-intrusive
774
writing is not possible. The internal IFDs and the MakerNote
775
(and thus the data buffer) may or may not be modified in this
778
bool updateEntries();
780
@brief Update the metadata for a range of entries. Called by
781
updateEntries() for each of the internal IFDs and the MakerNote
784
bool updateRange(const Entries::iterator& begin,
785
const Entries::iterator& end,
786
ByteOrder byteOrder);
788
@brief Write the Exif data to a data buffer the hard way, return the
789
data buffer. The caller owns this data buffer and %DataBuf
790
ensures that it will be deleted.
792
Rebuilds the Exif data from scratch, using the TIFF header, metadata
793
container and thumbnail. In particular, the internal IFDs and the
794
original data buffer are not used. Furthermore, this method updates
795
the Exif data with the metadata from the actual thumbnail image
796
(overriding existing metadata).
798
@return A %DataBuf containing the Exif data.
800
DataBuf copyFromMetadata();
806
@brief Check if the metadata is compatible with the internal IFDs for
807
non-intrusive writing. Return true if compatible, false if not.
809
@note This function does not detect deleted metadata as incompatible,
810
although the deletion of metadata is not (yet) a supported
811
non-intrusive write operation.
813
bool compatible() const;
815
@brief Find the IFD or makernote entry corresponding to ifd id and idx.
817
@return A pair of which the first part determines if a match was found
818
and, if true, the second contains an iterator to the entry.
820
std::pair<bool, Entries::const_iterator>
821
findEntry(IfdId ifdId, int idx) const;
822
//! Return a pointer to the internal IFD identified by its IFD id
823
const Ifd* getIfd(IfdId ifdId) const;
825
@brief Check if IFD1, the IFD1 data and thumbnail data are located at
826
the end of the Exif data. Return true, if they are or if there
827
is no thumbnail at all, else return false.
829
bool stdThumbPosition() const;
833
ExifMetadata exifMetadata_;
835
// The pointers below are used only if Exif data is read from a
837
TiffHeader* pTiffHeader_; //! Pointer to the TIFF header
838
Ifd* pIfd0_; //! Pointer to Ifd0
839
Ifd* pExifIfd_; //! Pointer to ExifIfd
840
Ifd* pIopIfd_; //! Pointer to IopIfd
841
Ifd* pGpsIfd_; //! Pointer to GpsIfd
842
Ifd* pIfd1_; //! Pointer to Ifd1
843
MakerNote* pMakerNote_; //! Pointer to the MakerNote, if any
845
long size_; //!< Size of the Exif raw data in bytes
846
byte* pData_; //!< Exif raw data buffer
849
Can be set to false to indicate that non-intrusive writing is not
850
possible. If it is true (the default), then the compatibility checks
851
will be performed to determine which writing method to use.
857
// *****************************************************************************
858
// template, inline and free functions
861
Exifdatum& setValue(Exifdatum& exifDatum, const T& value)
863
std::auto_ptr<ValueType<T> > v
864
= std::auto_ptr<ValueType<T> >(new ValueType<T>);
865
v->value_.push_back(value);
866
exifDatum.value_ = v;
870
@brief Add all metadata in the range from iterator position begin to
871
iterator position end, which have an IFD id matching that of the
872
IFD to the list of directory entries of ifd. No duplicate checks
873
are performed, i.e., it is possible to add multiple metadata with
874
the same key to an IFD.
876
void addToIfd(Ifd& ifd,
877
ExifMetadata::const_iterator begin,
878
ExifMetadata::const_iterator end,
879
ByteOrder byteOrder);
881
@brief Add the Exifdatum to the IFD. No duplicate checks are performed,
882
i.e., it is possible to add multiple metadata with the same key to
885
void addToIfd(Ifd& ifd, const Exifdatum& exifdatum, ByteOrder byteOrder);
887
@brief Add all metadata in the range from iterator position begin to
888
iterator position end with IFD id 'makerIfd' to the list of
889
makernote entries of the object pointed to be makerNote. No
890
duplicate checks are performed, i.e., it is possible to add
891
multiple metadata with the same key to a makernote.
893
void addToMakerNote(MakerNote* makerNote,
894
ExifMetadata::const_iterator begin,
895
ExifMetadata::const_iterator end,
896
ByteOrder byteOrder);
898
@brief Add the Exifdatum to makerNote, encoded in byte order byteOrder.
899
No duplicate checks are performed, i.e., it is possible to add
900
multiple metadata with the same key to a makernote.
902
void addToMakerNote(MakerNote* makerNote,
903
const Exifdatum& exifdatum,
904
ByteOrder byteOrder);
908
#endif // #ifndef EXIF_HPP_