Loading...
Searching...
No Matches
exif.hpp
Go to the documentation of this file.
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef EXIF_HPP_
#define EXIF_HPP_
// *****************************************************************************
#include "exiv2lib_export.h"
// included header files
#include "metadatum.hpp"
#include "tags.hpp"
// + standard includes
#include <list>
// *****************************************************************************
// namespace extensions
namespace Exiv2 {
// *****************************************************************************
// class declarations
class ExifData;
// *****************************************************************************
// class definitions
class EXIV2API Exifdatum : public Metadatum {
template <typename T>
friend Exifdatum& setValue(Exifdatum&, const T&);
public:
explicit Exifdatum(const ExifKey& key, const Value* pValue = nullptr);
Exifdatum(const Exifdatum& rhs);
~Exifdatum() override = default;
Exifdatum& operator=(const Exifdatum& rhs);
Exifdatum& operator=(const uint16_t& value);
Exifdatum& operator=(const uint32_t& value);
Exifdatum& operator=(const URational& value);
Exifdatum& operator=(const int16_t& value);
Exifdatum& operator=(const int32_t& value);
Exifdatum& operator=(const Rational& value);
Exifdatum& operator=(const std::string& value);
Exifdatum& operator=(const Value& value);
void setValue(const Value* pValue) override;
int setValue(const std::string& value) override;
int setDataArea(const byte* buf, size_t len) const;
[[nodiscard]] std::string key() const override;
[[nodiscard]] const char* familyName() const override;
[[nodiscard]] std::string groupName() const override;
[[nodiscard]] std::string tagName() const override;
[[nodiscard]] std::string tagLabel() const override;
[[nodiscard]] std::string tagDesc() const override;
[[nodiscard]] uint16_t tag() const override;
[[nodiscard]] IfdId ifdId() const;
[[nodiscard]] const char* ifdName() const;
[[nodiscard]] int idx() const;
size_t copy(byte* buf, ByteOrder byteOrder) const override;
std::ostream& write(std::ostream& os, const ExifData* pMetadata = nullptr) const override;
[[nodiscard]] TypeId typeId() const override;
[[nodiscard]] const char* typeName() const override;
[[nodiscard]] size_t typeSize() const override;
[[nodiscard]] size_t count() const override;
[[nodiscard]] size_t size() const override;
[[nodiscard]] std::string toString() const override;
[[nodiscard]] std::string toString(size_t n) const override;
[[nodiscard]] int64_t toInt64(size_t n = 0) const override;
[[nodiscard]] float toFloat(size_t n = 0) const override;
[[nodiscard]] Rational toRational(size_t n = 0) const override;
[[nodiscard]] Value::UniquePtr getValue() const override;
[[nodiscard]] const Value& value() const override;
[[nodiscard]] size_t sizeDataArea() const;
[[nodiscard]] DataBuf dataArea() const;
private:
// DATA
ExifKey::UniquePtr key_;
Value::UniquePtr value_;
}; // class Exifdatum
class EXIV2API ExifThumbC {
public:
explicit ExifThumbC(const ExifData& exifData);
[[nodiscard]] DataBuf copy() const;
#ifdef EXV_ENABLE_FILESYSTEM
[[nodiscard]] size_t writeFile(const std::string& path) const;
#endif
[[nodiscard]] const char* mimeType() const;
[[nodiscard]] const char* extension() const;
private:
// DATA
const ExifData& exifData_;
}; // class ExifThumb
class EXIV2API ExifThumb : public ExifThumbC {
public:
explicit ExifThumb(ExifData& exifData);
#ifdef EXV_ENABLE_FILESYSTEM
void setJpegThumbnail(const std::string& path, URational xres, URational yres, uint16_t unit);
#endif
void setJpegThumbnail(const byte* buf, size_t size, URational xres, URational yres, uint16_t unit);
#ifdef EXV_ENABLE_FILESYSTEM
void setJpegThumbnail(const std::string& path);
#endif
void setJpegThumbnail(const byte* buf, size_t size);
void erase();
private:
// DATA
ExifData& exifData_;
}; // class ExifThumb
using ExifMetadata = std::list<Exifdatum>;
class EXIV2API ExifData {
public:
using iterator = ExifMetadata::iterator;
using const_iterator = ExifMetadata::const_iterator;
Exifdatum& operator[](const std::string& key);
void add(const ExifKey& key, const Value* pValue);
void add(const Exifdatum& exifdatum);
iterator erase(iterator pos);
iterator erase(iterator beg, iterator end);
void clear();
void sortByKey();
void sortByTag();
iterator begin() {
return exifMetadata_.begin();
}
iterator end() {
return exifMetadata_.end();
}
iterator findKey(const ExifKey& key);
[[nodiscard]] const_iterator begin() const {
return exifMetadata_.begin();
}
[[nodiscard]] const_iterator end() const {
return exifMetadata_.end();
}
[[nodiscard]] const_iterator findKey(const ExifKey& key) const;
[[nodiscard]] bool empty() const {
return exifMetadata_.empty();
}
[[nodiscard]] size_t count() const {
return exifMetadata_.size();
}
private:
// DATA
ExifMetadata exifMetadata_;
}; // class ExifData
class EXIV2API ExifParser {
public:
static ByteOrder decode(ExifData& exifData, const byte* pData, size_t size);
static WriteMethod encode(Blob& blob, const byte* pData, size_t size, ByteOrder byteOrder, ExifData& exifData);
static void encode(Blob& blob, ByteOrder byteOrder, ExifData& exifData) {
encode(blob, nullptr, 0, byteOrder, exifData);
}
}; // class ExifParser
} // namespace Exiv2
#endif // #ifndef EXIF_HPP_
Exiv2::ExifData
A container for Exif data. This is a top-level class of the Exiv2 library. The container holds Exifda...
Definition exif.hpp:379
Exiv2::ExifData::empty
bool empty() const
Return true if there is no Exif metadata.
Definition exif.hpp:465
Exiv2::ExifData::count
size_t count() const
Get the number of metadata entries.
Definition exif.hpp:469
Exiv2::ExifData::iterator
ExifMetadata::iterator iterator
ExifMetadata iterator type.
Definition exif.hpp:382
Exiv2::ExifData::begin
iterator begin()
Begin of the metadata.
Definition exif.hpp:435
Exiv2::ExifData::end
const_iterator end() const
End of the metadata.
Definition exif.hpp:456
Exiv2::ExifData::end
iterator end()
End of the metadata.
Definition exif.hpp:439
Exiv2::ExifData::const_iterator
ExifMetadata::const_iterator const_iterator
ExifMetadata const iterator type.
Definition exif.hpp:384
Exiv2::ExifData::begin
const_iterator begin() const
Begin of the metadata.
Definition exif.hpp:452
Exiv2::ExifKey
Concrete keys for Exif metadata and access to Exif tag reference data.
Definition tags.hpp:271
Exiv2::ExifKey::UniquePtr
std::unique_ptr< ExifKey > UniquePtr
Shortcut for an ExifKey auto pointer.
Definition tags.hpp:274
Exiv2::ExifParser
Stateless parser class for Exif data. Images use this class to decode and encode binary Exif data.
Definition exif.hpp:485
Exiv2::ExifParser::encode
static void encode(Blob &blob, ByteOrder byteOrder, ExifData &exifData)
Encode metadata from the provided metadata to Exif format.
Definition exif.hpp:560
Exiv2::ExifThumbC
Access to a Exif thumbnail image. This class provides higher level accessors to the thumbnail image t...
Definition exif.hpp:217
Exiv2::ExifThumbC::writeFile
size_t writeFile(const std::string &path) const
Write the thumbnail image to a file.
Exiv2::ExifThumb
Access and modify an Exif thumbnail image. This class implements manipulators to set and erase the th...
Definition exif.hpp:274
Exiv2::ExifThumb::setJpegThumbnail
void setJpegThumbnail(const std::string &path, URational xres, URational yres, uint16_t unit)
Set the Exif thumbnail to the JPEG image path. Set XResolution, YResolution and ResolutionUnit to xre...
Exiv2::ExifThumb::setJpegThumbnail
void setJpegThumbnail(const std::string &path)
Set the Exif thumbnail to the JPEG image path.
Exiv2::Exifdatum
An Exif metadatum, consisting of an ExifKey and a Value and methods to manipulate these.
Definition exif.hpp:41
Exiv2::Exifdatum::~Exifdatum
~Exifdatum() override=default
Destructor.
Exiv2::Metadatum
Abstract base class defining the interface to access information related to one metadata tag.
Definition metadatum.hpp:103
Exiv2::Value
Common interface for all types of values used with metadata.
Definition value.hpp:33
Exiv2::Value::UniquePtr
std::unique_ptr< Value > UniquePtr
Shortcut for a Value auto pointer.
Definition value.hpp:36
Exiv2::Internal::groupName
const char * groupName(IfdId ifdId)
Return the group name for a group id.
Definition tags_int.cpp:2477
Exiv2::Internal::ifdName
const char * ifdName(IfdId ifdId)
Return the name of the IFD.
Definition tags_int.cpp:2471
Exiv2
Class CrwImage to access Canon CRW images. References: The Canon RAW (CRW) File Format by Phil Harv...
Definition asfvideo.hpp:15
Exiv2::Rational
std::pair< int32_t, int32_t > Rational
8 byte signed rational type.
Definition types.hpp:31
Exiv2::IfdId
IfdId
Type to specify the IFD to which a metadata belongs.
Definition tags.hpp:34
Exiv2::getValue
T getValue(const byte *buf, ByteOrder byteOrder)
Read a value of type T from the data buffer.
Exiv2::URational
std::pair< uint32_t, uint32_t > URational
8 byte unsigned rational type.
Definition types.hpp:29
Exiv2::TypeId
TypeId
Exiv2 value type identifiers.
Definition types.hpp:70
Exiv2::ByteOrder
ByteOrder
Type to express the byte order (little or big endian)
Definition types.hpp:34
Exiv2::WriteMethod
WriteMethod
Type to indicate write method used by TIFF parsers.
Definition types.hpp:41
Exiv2::ExifMetadata
std::list< Exifdatum > ExifMetadata
Container type to hold all metadata.
Definition exif.hpp:365
Exiv2::setValue
Exiv2::Exifdatum & setValue(Exiv2::Exifdatum &exifDatum, const T &value)
Set the value of exifDatum to value. If the object already has a value, it is replaced....
Definition exif.cpp:147
Exiv2::Blob
std::vector< byte > Blob
Container for binary data.
Definition types.hpp:102
Exiv2::DataBuf
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition types.hpp:124
Exiv2::mimeType
List of TIFF compression to MIME type mappings.
Definition tiffimage.cpp:47