github.com/cellofellow/gopkg@v0.0.0-20140722061823-eec0544a62ad/image/webp/libwebp/README.mux (about) 1 __ __ ____ ____ ____ __ __ _ __ __ 2 / \\/ \/ _ \/ _ \/ _ \/ \ \/ \___/_ / _\ 3 \ / __/ _ \ __/ / / (_/ /__ 4 \__\__/\_____/_____/__/ \__//_/\_____/__/___/v0.2.0 5 6 7 Description: 8 ============ 9 10 WebPMux: set of two libraries 'Mux' and 'Demux' for creation, extraction and 11 manipulation of an extended format WebP file, which can have features like 12 color profile, metadata and animation. Reference command-line tools 'webpmux' 13 and 'vwebp' as well as the WebP container specification 14 'doc/webp-container-spec.txt' are also provided in this package. 15 16 WebP Mux tool: 17 ============== 18 19 The examples/ directory contains a tool (webpmux) for manipulating WebP 20 files. The webpmux tool can be used to create an extended format WebP file and 21 also to extract or strip relevant data from such a file. 22 23 A list of options is available using the -help command line flag: 24 25 > webpmux -help 26 Usage: webpmux -get GET_OPTIONS INPUT -o OUTPUT 27 webpmux -set SET_OPTIONS INPUT -o OUTPUT 28 webpmux -strip STRIP_OPTIONS INPUT -o OUTPUT 29 webpmux -frame FRAME_OPTIONS [-frame...] [-loop LOOP_COUNT] 30 [-bgcolor BACKGROUND_COLOR] -o OUTPUT 31 webpmux -info INPUT 32 webpmux [-h|-help] 33 webpmux -version 34 35 GET_OPTIONS: 36 Extract relevant data. 37 icc Get ICC profile. 38 exif Get EXIF metadata. 39 xmp Get XMP metadata. 40 frame n Get nth frame. 41 42 SET_OPTIONS: 43 Set color profile/metadata. 44 icc file.icc Set ICC profile. 45 exif file.exif Set EXIF metadata. 46 xmp file.xmp Set XMP metadata. 47 where: 'file.icc' contains the ICC profile to be set, 48 'file.exif' contains the EXIF metadata to be set 49 'file.xmp' contains the XMP metadata to be set 50 51 STRIP_OPTIONS: 52 Strip color profile/metadata. 53 icc Strip ICC profile. 54 exif Strip EXIF metadata. 55 xmp Strip XMP metadata. 56 57 FRAME_OPTIONS(i): 58 Create animation. 59 file_i +di+[xi+yi[+mi[bi]]] 60 where: 'file_i' is the i'th animation frame (WebP format), 61 'di' is the pause duration before next frame. 62 'xi','yi' specify the image offset for this frame. 63 'mi' is the dispose method for this frame (0 or 1). 64 'bi' is the blending method for this frame (+b or -b). 65 66 LOOP_COUNT: 67 Number of times to repeat the animation. 68 Valid range is 0 to 65535 [Default: 0 (infinite)]. 69 70 BACKGROUND_COLOR: 71 Background color of the canvas. 72 A,R,G,B 73 where: 'A', 'R', 'G' and 'B' are integers in the range 0 to 255 specifying 74 the Alpha, Red, Green and Blue component values respectively 75 [Default: 255,255,255,255]. 76 77 INPUT & OUTPUT are in WebP format. 78 79 Note: The nature of EXIF, XMP and ICC data is not checked and is assumed to be 80 valid. 81 82 Visualization tool: 83 =================== 84 85 The examples/ directory also contains a tool (vwebp) for viewing WebP files. 86 It decodes the image and visualizes it using OpenGL. See the libwebp README 87 for details on building and running this program. 88 89 Mux API: 90 ======== 91 The Mux API contains methods for adding data to and reading data from WebP 92 files. This API currently supports XMP/EXIF metadata, ICC profile and animation. 93 Other features may be added in subsequent releases. 94 95 Example#1 (pseudo code): Creating a WebPMux object with image data, color 96 profile and XMP metadata. 97 98 int copy_data = 0; 99 WebPMux* mux = WebPMuxNew(); 100 // ... (Prepare image data). 101 WebPMuxSetImage(mux, &image, copy_data); 102 // ... (Prepare ICC profile data). 103 WebPMuxSetChunk(mux, "ICCP", &icc_profile, copy_data); 104 // ... (Prepare XMP metadata). 105 WebPMuxSetChunk(mux, "XMP ", &xmp, copy_data); 106 // Get data from mux in WebP RIFF format. 107 WebPMuxAssemble(mux, &output_data); 108 WebPMuxDelete(mux); 109 // ... (Consume output_data; e.g. write output_data.bytes to file). 110 WebPDataClear(&output_data); 111 112 113 Example#2 (pseudo code): Get image and color profile data from a WebP file. 114 115 int copy_data = 0; 116 // ... (Read data from file). 117 WebPMux* mux = WebPMuxCreate(&data, copy_data); 118 WebPMuxGetFrame(mux, 1, &image); 119 // ... (Consume image; e.g. call WebPDecode() to decode the data). 120 WebPMuxGetChunk(mux, "ICCP", &icc_profile); 121 // ... (Consume icc_profile). 122 WebPMuxDelete(mux); 123 free(data); 124 125 126 For a detailed Mux API reference, please refer to the header file 127 (src/webp/mux.h). 128 129 Demux API: 130 ========== 131 The Demux API enables extraction of images and extended format data from 132 WebP files. This API currently supports reading of XMP/EXIF metadata, ICC 133 profile and animated images. Other features may be added in subsequent 134 releases. 135 136 Code Example: Demuxing WebP data to extract all the frames, ICC profile 137 and EXIF/XMP metadata. 138 139 WebPDemuxer* demux = WebPDemux(&webp_data); 140 uint32_t width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH); 141 uint32_t height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT); 142 // ... (Get information about the features present in the WebP file). 143 uint32_t flags = WebPDemuxGetI(demux, WEBP_FF_FORMAT_FLAGS); 144 145 // ... (Iterate over all frames). 146 WebPIterator iter; 147 if (WebPDemuxGetFrame(demux, 1, &iter)) { 148 do { 149 // ... (Consume 'iter'; e.g. Decode 'iter.fragment' with WebPDecode(), 150 // ... and get other frame properties like width, height, offsets etc. 151 // ... see 'struct WebPIterator' below for more info). 152 } while (WebPDemuxNextFrame(&iter)); 153 WebPDemuxReleaseIterator(&iter); 154 } 155 156 // ... (Extract metadata). 157 WebPChunkIterator chunk_iter; 158 if (flags & ICCP_FLAG) WebPDemuxGetChunk(demux, "ICCP", 1, &chunk_iter); 159 // ... (Consume the ICC profile in 'chunk_iter.chunk'). 160 WebPDemuxReleaseChunkIterator(&chunk_iter); 161 if (flags & EXIF_FLAG) WebPDemuxGetChunk(demux, "EXIF", 1, &chunk_iter); 162 // ... (Consume the EXIF metadata in 'chunk_iter.chunk'). 163 WebPDemuxReleaseChunkIterator(&chunk_iter); 164 if (flags & XMP_FLAG) WebPDemuxGetChunk(demux, "XMP ", 1, &chunk_iter); 165 // ... (Consume the XMP metadata in 'chunk_iter.chunk'). 166 WebPDemuxReleaseChunkIterator(&chunk_iter); 167 WebPDemuxDelete(demux); 168 169 170 For a detailed Demux API reference, please refer to the header file 171 (src/webp/demux.h). 172 173 174 Bugs: 175 ===== 176 177 Please report all bugs to our issue tracker: 178 http://code.google.com/p/webp/issues 179 Patches welcome! See this page to get started: 180 http://www.webmproject.org/code/contribute/submitting-patches/ 181 182 Discuss: 183 ======== 184 185 Email: webp-discuss@webmproject.org 186 Web: http://groups.google.com/a/webmproject.org/group/webp-discuss