Exiv2
webpimage.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#ifndef WEBPIMAGE_HPP
21#define WEBPIMAGE_HPP
22
23// *****************************************************************************
24#include "exiv2lib_export.h"
25
26// included header files
27#include "image.hpp"
28
29// *****************************************************************************
30// namespace extensions
31namespace Exiv2 {
32
33// *****************************************************************************
34// class definitions
35
36 // Add WEBP to the supported image formats
37 namespace ImageType {
38 const int webp = 23;
39 }
40
44 class EXIV2API WebPImage:public Image
45 {
46 public:
48
49
60 explicit WebPImage(BasicIo::UniquePtr io);
62
64
65 void readMetadata() override;
66 void writeMetadata() override;
67 void printStructure(std::ostream& out, PrintStructureOption option, int depth) override;
69
73 void setComment(const std::string& comment) override;
74 void setIptcData(const IptcData& /*iptcData*/) override;
75
77
78 std::string mimeType() const override;
80
82 WebPImage(const WebPImage& rhs) = delete;
84 WebPImage& operator=(const WebPImage& rhs) = delete;
86
87 private:
88 void doWriteMetadata(BasicIo& outIo);
90
91 static long getHeaderOffset(const byte* data, long data_size, const byte* header, long header_size);
92 static bool equalsWebPTag(Exiv2::DataBuf& buf, const char* str);
93 void debugPrintHex(byte *data, long size);
94 void decodeChunks(long filesize);
95 void inject_VP8X(BasicIo& iIo, bool has_xmp, bool has_exif,
96 bool has_alpha, bool has_icc, int width,
97 int height);
98
99 static const byte WEBP_PAD_ODD;
100 static const int WEBP_TAG_SIZE;
101 static const int WEBP_VP8X_ICC_BIT;
102 static const int WEBP_VP8X_ALPHA_BIT;
103 static const int WEBP_VP8X_EXIF_BIT;
104 static const int WEBP_VP8X_XMP_BIT;
105 static const char* const WEBP_CHUNK_HEADER_VP8X;
106 static const char* const WEBP_CHUNK_HEADER_VP8L;
107 static const char* const WEBP_CHUNK_HEADER_VP8;
108 static const char* const WEBP_CHUNK_HEADER_ANMF;
109 static const char* const WEBP_CHUNK_HEADER_ANIM;
110 static const char* const WEBP_CHUNK_HEADER_ICCP;
111 static const char* const WEBP_CHUNK_HEADER_EXIF;
112 static const char* const WEBP_CHUNK_HEADER_XMP;
113
114 }; //Class WebPImage
115
116// *****************************************************************************
117// template, inline and free functions
118
119 // These could be static private functions on Image subclasses but then
120 // ImageFactory needs to be made a friend.
126 EXIV2API Image::UniquePtr newWebPInstance(BasicIo::UniquePtr io, bool create);
127
129 EXIV2API bool isWebPType(BasicIo& iIo, bool advance);
130
131} // namespace Exiv2
132
133#endif // WEBPIMAGE_HPP
An interface for simple binary IO.
Definition: basicio.hpp:55
std::unique_ptr< BasicIo > UniquePtr
BasicIo auto_ptr type.
Definition: basicio.hpp:58
Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2...
Definition: image.hpp:78
std::unique_ptr< Image > UniquePtr
Image auto_ptr type.
Definition: image.hpp:81
A container for IPTC data. This is a top-level class of the Exiv2 library.
Definition: iptc.hpp:169
Class to access WEBP video files.
Definition: webpimage.hpp:45
WebPImage & operator=(const WebPImage &rhs)=delete
Assignment operator.
WebPImage(const WebPImage &rhs)=delete
Copy constructor.
const int webp
Treating webp as an image type>
Definition: webpimage.hpp:38
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: basicio.hpp:43
PrintStructureOption
Options for printStructure.
Definition: image.hpp:64
@ comment
Exiv2 type for the Exif user comment.
Definition: types.hpp:120
EXIV2API bool isWebPType(BasicIo &iIo, bool advance)
Check if the file iIo is a WebP Video.
Definition: webpimage.cpp:750
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:741
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition: types.hpp:162