| Exiv2

Loading...
Searching...
No Matches
webpimage.hpp
1// SPDX-License-Identifier: GPL-2.0-or-later
2
3#ifndef WEBPIMAGE_HPP
4#define WEBPIMAGE_HPP
5
6// *****************************************************************************
7#include "exiv2lib_export.h"
8
9// included header files
10#include "image.hpp"
11
12// *****************************************************************************
13// namespace extensions
14 namespace Exiv2 {
15// *****************************************************************************
16// class definitions
17
21 class EXIV2API WebPImage : public Image {
22 public:
24
25
36 explicit WebPImage(BasicIo::UniquePtr io);
38
40
41 void readMetadata() override;
42 void writeMetadata() override;
43 void printStructure(std::ostream& out, PrintStructureOption option, size_t depth) override;
45
49 void setComment(const std::string&) override;
50 void setIptcData(const IptcData& /*iptcData*/) override;
51
53
54 [[nodiscard]] std::string mimeType() const override;
56
57 private:
58 void doWriteMetadata(BasicIo& outIo);
59
61 static size_t getHeaderOffset(const byte* data, size_t data_size, const byte* header, size_t header_size);
62
63 static bool equalsWebPTag(const Exiv2::DataBuf& buf, const char* str);
64 void debugPrintHex(byte* data, size_t size);
65 void decodeChunks(uint32_t filesize);
66 void inject_VP8X(BasicIo& iIo, bool has_xmp, bool has_exif, bool has_alpha, bool has_icc, uint32_t width,
67 uint32_t height) const;
68 /* Misc. */
69 static constexpr byte WEBP_PAD_ODD = 0;
70 static constexpr int WEBP_TAG_SIZE = 0x4;
71 /* VP8X feature flags */
72 static constexpr int WEBP_VP8X_ICC_BIT = 0x20;
73 static constexpr int WEBP_VP8X_ALPHA_BIT = 0x10;
74 static constexpr int WEBP_VP8X_EXIF_BIT = 0x8;
75 static constexpr int WEBP_VP8X_XMP_BIT = 0x4;
76 /* Chunk header names */
77 static constexpr auto WEBP_CHUNK_HEADER_VP8X = "VP8X";
78 static constexpr auto WEBP_CHUNK_HEADER_VP8L = "VP8L";
79 static constexpr auto WEBP_CHUNK_HEADER_VP8 = "VP8 ";
80 static constexpr auto WEBP_CHUNK_HEADER_ANMF = "ANMF";
81 static constexpr auto WEBP_CHUNK_HEADER_ANIM = "ANIM";
82 static constexpr auto WEBP_CHUNK_HEADER_ICCP = "ICCP";
83 static constexpr auto WEBP_CHUNK_HEADER_EXIF = "EXIF";
84 static constexpr auto WEBP_CHUNK_HEADER_XMP = "XMP ";
85}; // Class WebPImage
86
87// *****************************************************************************
88// template, inline and free functions
89
90// These could be static private functions on Image subclasses but then
91// ImageFactory needs to be made a friend.
97EXIV2API Image::UniquePtr newWebPInstance(BasicIo::UniquePtr io, bool create);
98
100EXIV2API bool isWebPType(BasicIo& iIo, bool advance);
101
102} // namespace Exiv2
103
104#endif // WEBPIMAGE_HPP
Exiv2::BasicIo
An interface for simple binary IO.
Definition basicio.hpp:35
Exiv2::BasicIo::UniquePtr
std::unique_ptr< BasicIo > UniquePtr
BasicIo auto_ptr type.
Definition basicio.hpp:38
Exiv2::Image::Image
Image(ImageType type, uint16_t supportedMetadata, BasicIo::UniquePtr io)
Constructor taking the image type, a bitmap of the supported metadata types and an auto-pointer that ...
Definition image.cpp:132
Exiv2::Image::io
virtual BasicIo & io() const
Return a reference to the BasicIo instance being used for Io.
Definition image.cpp:696
Exiv2::Image::UniquePtr
std::unique_ptr< Image > UniquePtr
Image auto_ptr type.
Definition image.hpp:53
Exiv2::IptcData
A container for IPTC data. This is a top-level class of the Exiv2 library.
Definition iptc.hpp:153
Exiv2::WebPImage::setComment
void setComment(const std::string &) override
Not supported. Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
Definition webpimage.cpp:86
Exiv2::WebPImage::mimeType
std::string mimeType() const override
Return the MIME type of the image.
Definition webpimage.cpp:76
Exiv2::WebPImage::writeMetadata
void writeMetadata() override
Write metadata back to the image.
Definition webpimage.cpp:93
Exiv2::WebPImage::printStructure
void printStructure(std::ostream &out, PrintStructureOption option, size_t depth) override
Print out the structure of image file.
Definition webpimage.cpp:408
Exiv2::WebPImage::readMetadata
void readMetadata() override
Read all metadata supported by a specific image format from the image. Before this method is called,...
Definition webpimage.cpp:472
Exiv2::WebPImage::WebPImage
WebPImage(BasicIo::UniquePtr io)
Constructor for a WebP video. Since the constructor can not return a result, callers should check the...
Definition webpimage.cpp:73
Exiv2::WebPImage::setIptcData
void setIptcData(const IptcData &) override
Assign new IPTC data. The new IPTC data is not written to the image until the writeMetadata() method ...
Definition webpimage.cpp:80
Exiv2
Class CrwImage to access Canon CRW images. References: The Canon RAW (CRW) File Format by Phil Harv...
Definition asfvideo.hpp:15
Exiv2::PrintStructureOption
PrintStructureOption
Options for printStructure.
Definition image.hpp:38
Exiv2::isWebPType
EXIV2API bool isWebPType(BasicIo &iIo, bool advance)
Check if the file iIo is a WebP Video.
Definition webpimage.cpp:699
Exiv2::newWebPInstance
EXIV2API Image::UniquePtr newWebPInstance(BasicIo::UniquePtr io, bool create)
Create a new WebPImage instance and return an auto-pointer to it. Caller owns the returned object and...
Definition webpimage.cpp:691
Exiv2::DataBuf
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition types.hpp:124