Exiv2
tiffimage.hpp
1 // ***************************************************************** -*- C++ -*-
2 /*
3  * Copyright (C) 2004-2021 Exiv2 authors
4  * This program is part of the Exiv2 distribution.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef TIFFIMAGE_HPP_
22 #define TIFFIMAGE_HPP_
23 
24 // *****************************************************************************
25 #include "exiv2lib_export.h"
26 
27 // included header files
28 #include "image.hpp"
29 
30 // *****************************************************************************
31 // namespace extensions
32 namespace Exiv2 {
33 
34 // *****************************************************************************
35 // class definitions
36 
37  // Add TIFF to the supported image formats
38  namespace ImageType {
39  const int tiff = 4;
40  const int dng = 4;
41  const int nef = 4;
42  const int pef = 4;
43  const int arw = 4;
44  const int sr2 = 4;
45  const int srw = 4;
46  }
47 
52  class EXIV2API TiffImage : public Image {
53  public:
55 
56 
71  TiffImage(BasicIo::AutoPtr io, bool create);
73 
75 
76  void readMetadata();
77  void writeMetadata();
78 
85  virtual void printStructure(std::ostream& out, PrintStructureOption option,int depth=0);
86 
91  void setComment(const std::string& comment);
93 
95 
96  std::string mimeType() const;
97  int pixelWidth() const;
98  int pixelHeight() const;
100 
101  private:
103 
104  TiffImage(const TiffImage& rhs);
107  TiffImage& operator=(const TiffImage& rhs);
109 
111 
112  std::string primaryGroup() const;
115 
116  private:
117  // DATA
118  mutable std::string primaryGroup_;
119  mutable std::string mimeType_;
120  mutable int pixelWidth_;
121  mutable int pixelHeight_;
122 
123  }; // class TiffImage
124 
130  class EXIV2API TiffParser {
131  public:
145  static ByteOrder decode(
146  ExifData& exifData,
147  IptcData& iptcData,
148  XmpData& xmpData,
149  const byte* pData,
150  uint32_t size
151  );
185  static WriteMethod encode(
186  BasicIo& io,
187  const byte* pData,
188  uint32_t size,
189  ByteOrder byteOrder,
190  const ExifData& exifData,
191  const IptcData& iptcData,
192  const XmpData& xmpData
193  );
194 
195  }; // class TiffParser
196 
197 // *****************************************************************************
198 // template, inline and free functions
199 
200  // These could be static private functions on Image subclasses but then
201  // ImageFactory needs to be made a friend.
207  EXIV2API Image::AutoPtr newTiffInstance(BasicIo::AutoPtr io, bool create);
208 
210  EXIV2API bool isTiffType(BasicIo& iIo, bool advance);
211 
212 } // namespace Exiv2
213 
214 #endif // #ifndef TIFFIMAGE_HPP_
Exiv2::ImageType::sr2
const int sr2
SR2 image type (see class TiffImage)
Definition: tiffimage.hpp:44
Exiv2::TiffImage::writeMetadata
void writeMetadata()
Write metadata back to the image.
Definition: tiffimage.cpp:205
Exiv2::BasicIo::error
virtual int error() const =0
Returns 0 if the IO source is in a valid state, otherwise nonzero.
Exiv2::DataBuf::pData_
byte * pData_
Pointer to the buffer, 0 if none has been allocated.
Definition: types.hpp:258
nikonmn_int.hpp
Nikon makernote tags. References: [1] MakerNote EXIF Tag of the Nikon 990 by Max Lyons [2] Exif fil...
Exiv2::Image::iptcData_
IptcData iptcData_
IPTC data container.
Definition: image.hpp:486
Exiv2::IoCloser
Utility class that closes a BasicIo instance upon destruction. Meant to be used as a stack variable i...
Definition: basicio.hpp:264
Exiv2::ExifData::findKey
iterator findKey(const ExifKey &key)
Find the first Exifdatum with the given key, return an iterator to it.
Definition: exif.cpp:605
Exiv2::ImageType::tiff
const int tiff
TIFF image type (see class TiffImage)
Definition: tiffimage.hpp:39
Exiv2::ExifData::add
void add(const ExifKey &key, const Value *pValue)
Add an Exifdatum from the supplied key and value pair. This method copies (clones) key and value....
Definition: exif.cpp:588
Exiv2::MimeTypeList::operator==
bool operator==(int compression) const
Comparison operator for compression.
Definition: tiffimage.cpp:79
Exiv2::TiffImage::printStructure
virtual void printStructure(std::ostream &out, PrintStructureOption option, int depth=0)
Print out the structure of image file.
Definition: tiffimage.cpp:342
Exiv2::Internal::IfdId
IfdId
Type to specify the IFD to which a metadata belongs.
Definition: tags_int.hpp:46
Exiv2::ExifData::begin
iterator begin()
Begin of the metadata.
Definition: exif.hpp:490
Exiv2::ExifData::const_iterator
ExifMetadata::const_iterator const_iterator
ExifMetadata const iterator type.
Definition: exif.hpp:439
Exiv2::Internal::TiffHeader
Standard TIFF header structure.
Definition: tiffimage_int.hpp:142
Exiv2::TiffImage::pixelHeight
int pixelHeight() const
Return the pixel height of the image.
Definition: tiffimage.cpp:148
Exiv2::ImageType::nef
const int nef
NEF image type (see class TiffImage)
Definition: tiffimage.hpp:41
Exiv2::ExifData::erase
iterator erase(iterator pos)
Delete the Exifdatum at iterator position pos, return the position of the next exifdatum....
Definition: exif.cpp:631
Exiv2::comment
@ comment
Exiv2 type for the Exif user comment.
Definition: types.hpp:139
Exiv2::TiffImage::mimeType
std::string mimeType() const
Return the MIME type of the image.
Definition: tiffimage.cpp:91
Exiv2::TiffImage::TiffImage
TiffImage(BasicIo::AutoPtr io, bool create)
Constructor that can either open an existing TIFF image or create a new image from scratch....
Definition: tiffimage.cpp:70
Exiv2::strError
EXIV2API std::string strError()
Return a system error message and the error code (errno). See strerror(3).
Definition: futils.cpp:316
Exiv2::Internal::FindExifdatum
Unary predicate that matches an Exifdatum with a given IfdId.
Definition: tiffimage_int.hpp:469
Exiv2::mimeTypeList
MimeTypeList mimeTypeList[]
List of TIFF compression to MIME type mappings.
Definition: tiffimage.cpp:85
Exiv2::Internal::TiffHeaderBase::read
virtual bool read(const byte *pData, uint32_t size)
Read the image header from a data buffer. Return false if the data buffer does not contain an image h...
Definition: tiffimage_int.cpp:1900
Exiv2::Image::exifData_
ExifData exifData_
Exif data container.
Definition: image.hpp:485
Exiv2::TiffParser::decode
static ByteOrder decode(ExifData &exifData, IptcData &iptcData, XmpData &xmpData, const byte *pData, uint32_t size)
Decode metadata from a buffer pData of length size with data in TIFF format to the provided metadata ...
Definition: tiffimage.cpp:248
Exiv2::newTiffInstance
EXIV2API Image::AutoPtr newTiffInstance(BasicIo::AutoPtr io, bool create)
Create a new TiffImage instance and return an auto-pointer to it. Caller owns the returned object and...
Definition: tiffimage.cpp:317
Exiv2::ExifData::end
iterator end()
End of the metadata.
Definition: exif.hpp:492
Exiv2::MimeTypeList
Structure for TIFF compression to MIME type mappings.
Definition: tiffimage.cpp:77
Exiv2::isTiffType
EXIV2API bool isTiffType(BasicIo &iIo, bool advance)
Check if the file iIo is a TIFF image.
Definition: tiffimage.cpp:326
Exiv2::Image::iccProfileDefined
virtual bool iccProfileDefined()
Erase iccProfile. the profile is not removed from the actual image until the writeMetadata() method i...
Definition: image.hpp:235
Exiv2::Image::clearMetadata
virtual void clearMetadata()
Erase all buffered metadata. Metadata is not removed from the actual image until the writeMetadata() ...
Definition: image.cpp:570
Exiv2::DataValue
Value for an undefined data type.
Definition: value.hpp:253
Exiv2::Internal::TiffMapping::findEncoder
static EncoderFct findEncoder(const std::string &make, uint32_t extendedTag, IfdId group)
Find special encoder function for a key.
Definition: tiffimage_int.cpp:1654
Exiv2::TiffImage::readMetadata
void readMetadata()
Read all metadata supported by a specific image format from the image. Before this method is called,...
Definition: tiffimage.cpp:166
Exiv2::Internal::TiffMapping::findDecoder
static DecoderFct findDecoder(const std::string &make, uint32_t extendedTag, IfdId group)
Find the decoder function for a key.
Definition: tiffimage_int.cpp:1640
Exiv2::MimeTypeList::compression_
int compression_
TIFF compression.
Definition: tiffimage.cpp:80
Exiv2::Image::setByteOrder
void setByteOrder(ByteOrder byteOrder)
Set the byte order to encode the Exif metadata in.
Definition: image.cpp:707
Exiv2::Image::byteOrder
ByteOrder byteOrder() const
Return the byte order in which the Exif metadata of the image is encoded. Initially,...
Definition: image.cpp:712
Exiv2::Image::printTiffStructure
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:552
Exiv2::TiffImage::pixelWidth
int pixelWidth() const
Return the pixel width of the image.
Definition: tiffimage.cpp:136
Exiv2::DataBuf::alloc
void alloc(long size)
Allocate a data buffer of at least the given size. Note that if the requested size is less than the c...
Definition: types.cpp:156
Exiv2::ExifKey
Concrete keys for Exif metadata and access to Exif tag reference data.
Definition: tags.hpp:140
Exiv2::DataBuf::size_
long size_
The current size of the buffer.
Definition: types.hpp:260
Exiv2::BasicIo::eof
virtual bool eof() const =0
Returns true if the IO position has reached the end, otherwise false.
Exiv2::find
const T * find(T(&src)[N], const K &key)
Find an element that matches key in the array src.
Definition: types.hpp:497
Exiv2::BasicIo::read
virtual DataBuf read(long rcount)=0
Read data from the IO source. Reading starts at the current IO position and the position is advanced ...
Exiv2::Image::imageType
int imageType() const
set type support for this image format
Definition: image.hpp:480
Exiv2
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
Exiv2::XmpData
A container for XMP data. This is a top-level class of the Exiv2 library.
Definition: xmp_exiv2.hpp:166
Exiv2::Image::io
virtual BasicIo & io() const
Return a reference to the BasicIo instance being used for Io.
Definition: image.cpp:752
Exiv2::ImageType::pef
const int pef
PEF image type (see class TiffImage)
Definition: tiffimage.hpp:42
Exiv2::ImageType::none
const int none
Not an image.
Definition: image.hpp:45
Exiv2::TiffParser
Stateless parser class for data in TIFF format. Images use this class to decode and encode TIFF data....
Definition: tiffimage.hpp:130
Exiv2::TiffImage
Class to access TIFF images. Exif metadata is supported directly, IPTC is read from the Exif data,...
Definition: tiffimage.hpp:52
Exiv2::TiffParser::encode
static WriteMethod encode(BasicIo &io, const byte *pData, uint32_t size, ByteOrder byteOrder, const ExifData &exifData, const IptcData &iptcData, const XmpData &xmpData)
Encode metadata from the provided metadata to TIFF format.
Definition: tiffimage.cpp:275
Exiv2::Internal::TiffParserWorker::encode
static WriteMethod encode(BasicIo &io, const byte *pData, uint32_t size, const ExifData &exifData, const IptcData &iptcData, const XmpData &xmpData, uint32_t root, FindEncoderFct findEncoderFct, TiffHeaderBase *pHeader, OffsetWriter *pOffsetWriter)
Encode TIFF metadata from the metadata containers into a memory block blob.
Definition: tiffimage_int.cpp:1747
Exiv2::Image::io_
BasicIo::AutoPtr io_
Image data IO pointer.
Definition: image.hpp:484
Exiv2::TiffImage::setComment
void setComment(const std::string &comment)
Not supported. TIFF format does not contain a comment. Calling this function will throw an Error(kerI...
Definition: tiffimage.cpp:160
Exiv2::ByteOrder
ByteOrder
Type to express the byte order (little or big endian)
Definition: types.hpp:102
Exiv2::Image::iccProfile_
DataBuf iccProfile_
ICC buffer (binary data)
Definition: image.hpp:488
Exiv2::XmpData::usePacket
bool usePacket() const
are we to use the packet?
Definition: xmp_exiv2.hpp:245
Exiv2::ImageType::dng
const int dng
DNG image type (see class TiffImage)
Definition: tiffimage.hpp:40
Exiv2::Image::AutoPtr
std::auto_ptr< Image > AutoPtr
Image auto_ptr type.
Definition: image.hpp:81
Exiv2::BasicIo::AutoPtr
std::auto_ptr< BasicIo > AutoPtr
BasicIo auto_ptr type.
Definition: basicio.hpp:58
Exiv2::Image::writeXmpFromPacket
bool writeXmpFromPacket() const
Return the flag indicating the source when writing XMP metadata.
Definition: image.cpp:757
Exiv2::Error
BasicError< char > Error
Error class used for exceptions (std::string based)
Definition: error.hpp:324
Exiv2::IptcData
A container for IPTC data. This is a top-level class of the Exiv2 library.
Definition: iptc.hpp:170
Exiv2::MimeTypeList::mimeType_
const char * mimeType_
MIME type.
Definition: tiffimage.cpp:81
Exiv2::ImageType::arw
const int arw
ARW image type (see class TiffImage)
Definition: tiffimage.hpp:43
Exiv2::PrintStructureOption
PrintStructureOption
Options for printStructure.
Definition: image.hpp:64
Exiv2::BasicIo::seek
virtual int seek(long offset, Position pos)=0
Move the current IO position.
Exiv2::ExifData::iterator
ExifMetadata::iterator iterator
ExifMetadata iterator type.
Definition: exif.hpp:437
Exiv2::BasicIo
An interface for simple binary IO.
Definition: basicio.hpp:55
Exiv2::Image::xmpData_
XmpData xmpData_
XMP data container.
Definition: image.hpp:487
Exiv2::Image::xmpData
virtual XmpData & xmpData()
Returns an XmpData instance containing currently buffered XMP data.
Definition: image.cpp:590
Exiv2::Image
Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2...
Definition: image.hpp:78
Exiv2::WriteMethod
WriteMethod
Type to indicate write method used by TIFF parsers.
Definition: types.hpp:105
Exiv2::ImageType::srw
const int srw
SRW image type (see class TiffImage)
Definition: tiffimage.hpp:45
Exiv2::Internal::TiffHeaderBase::byteOrder
virtual ByteOrder byteOrder() const
Return the byte order (little or big endian).
Definition: tiffimage_int.cpp:1956
Exiv2::Internal::TiffParserWorker::decode
static ByteOrder decode(ExifData &exifData, IptcData &iptcData, XmpData &xmpData, const byte *pData, uint32_t size, uint32_t root, FindDecoderFct findDecoderFct, TiffHeaderBase *pHeader=0)
Decode TIFF metadata from a data buffer pData of length size into the provided metadata containers.
Definition: tiffimage_int.cpp:1717
error.hpp
Error class for exceptions, log message class.
Exiv2::ExifData
A container for Exif data. This is a top-level class of the Exiv2 library. The container holds Exifda...
Definition: exif.hpp:434