2011-09-30 07:19:26 +02:00
|
|
|
__ __ ____ ____ ____ __ __ _ __ __
|
|
|
|
/ \\/ \/ _ \/ _ \/ _ \/ \ \/ \___/_ / _\
|
|
|
|
\ / __/ _ \ __/ / / (_/ /__
|
2013-06-12 23:58:32 +02:00
|
|
|
\__\__/\_____/_____/__/ \__//_/\_____/__/___/v0.1.1
|
2011-09-30 07:19:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
Description:
|
|
|
|
============
|
|
|
|
|
2013-02-22 01:56:48 +01:00
|
|
|
WebPMux: set of two libraries 'Mux' and 'Demux' for creation, extraction and
|
|
|
|
manipulation of an extended format WebP file, which can have features like
|
2013-03-16 20:35:49 +01:00
|
|
|
color profile, metadata and animation. Reference command-line tools 'webpmux'
|
|
|
|
and 'vwebp' as well as the WebP container specification
|
|
|
|
'doc/webp-container-spec.txt' are also provided in this package.
|
2011-09-30 07:19:26 +02:00
|
|
|
|
|
|
|
WebP Mux tool:
|
|
|
|
==============
|
|
|
|
|
2012-02-17 23:39:31 +01:00
|
|
|
The examples/ directory contains a tool (webpmux) for manipulating WebP
|
2013-02-22 01:56:48 +01:00
|
|
|
files. The webpmux tool can be used to create an extended format WebP file and
|
|
|
|
also to extract or strip relevant data from such a file.
|
2011-09-30 07:19:26 +02:00
|
|
|
|
|
|
|
A list of options is available using the -help command line flag:
|
|
|
|
|
|
|
|
> webpmux -help
|
|
|
|
Usage: webpmux -get GET_OPTIONS INPUT -o OUTPUT
|
2012-01-24 21:46:46 +01:00
|
|
|
webpmux -set SET_OPTIONS INPUT -o OUTPUT
|
|
|
|
webpmux -strip STRIP_OPTIONS INPUT -o OUTPUT
|
2012-11-01 23:34:46 +01:00
|
|
|
webpmux -frame FRAME_OPTIONS [-frame...] [-loop LOOP_COUNT]
|
|
|
|
[-bgcolor BACKGROUND_COLOR] -o OUTPUT
|
2012-01-24 21:46:46 +01:00
|
|
|
webpmux -info INPUT
|
|
|
|
webpmux [-h|-help]
|
2013-02-26 23:22:06 +01:00
|
|
|
webpmux -version
|
2011-09-30 07:19:26 +02:00
|
|
|
|
|
|
|
GET_OPTIONS:
|
2012-01-24 21:46:46 +01:00
|
|
|
Extract relevant data.
|
2012-11-01 00:30:41 +01:00
|
|
|
icc Get ICC profile.
|
|
|
|
exif Get EXIF metadata.
|
|
|
|
xmp Get XMP metadata.
|
2011-09-30 07:19:26 +02:00
|
|
|
frame n Get nth frame.
|
|
|
|
|
|
|
|
SET_OPTIONS:
|
2012-01-24 21:46:46 +01:00
|
|
|
Set color profile/metadata.
|
2012-11-01 00:30:41 +01:00
|
|
|
icc file.icc Set ICC profile.
|
|
|
|
exif file.exif Set EXIF metadata.
|
|
|
|
xmp file.xmp Set XMP metadata.
|
|
|
|
where: 'file.icc' contains the ICC profile to be set,
|
2013-03-16 20:35:49 +01:00
|
|
|
'file.exif' contains the EXIF metadata to be set
|
2012-11-01 00:30:41 +01:00
|
|
|
'file.xmp' contains the XMP metadata to be set
|
2011-09-30 07:19:26 +02:00
|
|
|
|
|
|
|
STRIP_OPTIONS:
|
2012-01-24 21:46:46 +01:00
|
|
|
Strip color profile/metadata.
|
2012-11-01 00:30:41 +01:00
|
|
|
icc Strip ICC profile.
|
|
|
|
exif Strip EXIF metadata.
|
|
|
|
xmp Strip XMP metadata.
|
2011-09-30 07:19:26 +02:00
|
|
|
|
|
|
|
FRAME_OPTIONS(i):
|
2012-01-24 21:46:46 +01:00
|
|
|
Create animation.
|
2013-03-11 21:58:34 +01:00
|
|
|
file_i +di+xi+yi+mi
|
2012-11-01 00:30:41 +01:00
|
|
|
where: 'file_i' is the i'th animation frame (WebP format),
|
2011-09-30 07:19:26 +02:00
|
|
|
'di' is the pause duration before next frame.
|
2013-03-11 21:58:34 +01:00
|
|
|
'xi','yi' specify the image offset for this frame.
|
2012-11-01 23:34:46 +01:00
|
|
|
'mi' is the dispose method for this frame (0 or 1).
|
2011-09-30 07:19:26 +02:00
|
|
|
|
2012-11-01 23:34:46 +01:00
|
|
|
LOOP_COUNT:
|
|
|
|
Number of times to repeat the animation.
|
|
|
|
Valid range is 0 to 65535 [Default: 0 (infinite)].
|
|
|
|
|
|
|
|
BACKGROUND_COLOR:
|
|
|
|
Background color of the canvas.
|
|
|
|
A,R,G,B
|
|
|
|
where: 'A', 'R', 'G' and 'B' are integers in the range 0 to 255 specifying
|
|
|
|
the Alpha, Red, Green and Blue component values respectively
|
|
|
|
[Default: 255,255,255,255].
|
|
|
|
|
|
|
|
INPUT & OUTPUT are in WebP format.
|
2012-11-01 00:30:41 +01:00
|
|
|
|
|
|
|
Note: The nature of EXIF, XMP and ICC data is not checked and is assumed to be
|
|
|
|
valid.
|
2011-09-30 07:19:26 +02:00
|
|
|
|
2013-03-16 20:35:49 +01:00
|
|
|
Visualization tool:
|
|
|
|
===================
|
2013-02-22 01:56:48 +01:00
|
|
|
|
|
|
|
The examples/ directory also contains a tool (vwebp) for viewing WebP files.
|
2013-03-16 20:35:49 +01:00
|
|
|
It decodes the image and visualizes it using OpenGL. See the libwebp README
|
|
|
|
for details on building and running this program.
|
2013-02-22 01:56:48 +01:00
|
|
|
|
|
|
|
Mux API:
|
|
|
|
========
|
|
|
|
The Mux API contains methods for adding data to and reading data from WebP
|
2013-03-16 20:35:49 +01:00
|
|
|
files. This API currently supports XMP/EXIF metadata, ICC profile and animation.
|
|
|
|
Other features may be added in subsequent releases.
|
2011-09-30 07:19:26 +02:00
|
|
|
|
2012-02-17 23:39:31 +01:00
|
|
|
Example#1 (pseudo code): Creating a WebPMux object with image data, color
|
2012-11-01 00:30:41 +01:00
|
|
|
profile and XMP metadata.
|
2011-09-30 07:19:26 +02:00
|
|
|
|
|
|
|
int copy_data = 0;
|
|
|
|
WebPMux* mux = WebPMuxNew();
|
|
|
|
// ... (Prepare image data).
|
2012-06-20 19:59:40 +02:00
|
|
|
WebPMuxSetImage(mux, &image, copy_data);
|
2012-11-01 00:30:41 +01:00
|
|
|
// ... (Prepare ICC profile data).
|
2012-08-23 11:58:20 +02:00
|
|
|
WebPMuxSetChunk(mux, "ICCP", &icc_profile, copy_data);
|
2011-09-30 07:19:26 +02:00
|
|
|
// ... (Prepare XMP metadata).
|
2012-11-01 00:30:41 +01:00
|
|
|
WebPMuxSetChunk(mux, "XMP ", &xmp, copy_data);
|
2011-09-30 07:19:26 +02:00
|
|
|
// Get data from mux in WebP RIFF format.
|
2012-06-07 07:34:57 +02:00
|
|
|
WebPMuxAssemble(mux, &output_data);
|
2011-09-30 07:19:26 +02:00
|
|
|
WebPMuxDelete(mux);
|
2012-10-30 22:54:46 +01:00
|
|
|
// ... (Consume output_data; e.g. write output_data.bytes to file).
|
2012-06-07 07:34:57 +02:00
|
|
|
WebPDataClear(&output_data);
|
2011-09-30 07:19:26 +02:00
|
|
|
|
|
|
|
|
2012-11-01 00:30:41 +01:00
|
|
|
Example#2 (pseudo code): Get image and color profile data from a WebP file.
|
2011-09-30 07:19:26 +02:00
|
|
|
|
|
|
|
int copy_data = 0;
|
|
|
|
// ... (Read data from file).
|
2012-06-05 16:58:03 +02:00
|
|
|
WebPMux* mux = WebPMuxCreate(&data, copy_data);
|
2012-08-23 12:58:36 +02:00
|
|
|
WebPMuxGetFrame(mux, 1, &image);
|
2012-01-07 21:44:01 +01:00
|
|
|
// ... (Consume image; e.g. call WebPDecode() to decode the data).
|
2012-08-23 11:58:20 +02:00
|
|
|
WebPMuxGetChunk(mux, "ICCP", &icc_profile);
|
2012-06-05 16:58:03 +02:00
|
|
|
// ... (Consume icc_profile).
|
2011-09-30 07:19:26 +02:00
|
|
|
WebPMuxDelete(mux);
|
|
|
|
free(data);
|
|
|
|
|
|
|
|
|
2013-02-22 01:56:48 +01:00
|
|
|
For a detailed Mux API reference, please refer to the header file
|
|
|
|
(src/webp/mux.h).
|
|
|
|
|
|
|
|
Demux API:
|
2013-03-16 20:35:49 +01:00
|
|
|
==========
|
2013-02-22 01:56:48 +01:00
|
|
|
The Demux API enables extraction of images and extended format data from
|
|
|
|
WebP files. This API currently supports reading of XMP/EXIF metadata, ICC
|
2013-03-16 20:35:49 +01:00
|
|
|
profile and animated images. Other features may be added in subsequent
|
|
|
|
releases.
|
2013-02-22 01:56:48 +01:00
|
|
|
|
|
|
|
Code Example: Demuxing WebP data to extract all the frames, ICC profile
|
|
|
|
and EXIF/XMP metadata.
|
|
|
|
|
|
|
|
WebPDemuxer* demux = WebPDemux(&webp_data);
|
|
|
|
uint32_t width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH);
|
|
|
|
uint32_t height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT);
|
|
|
|
// ... (Get information about the features present in the WebP file).
|
|
|
|
uint32_t flags = WebPDemuxGetI(demux, WEBP_FF_FORMAT_FLAGS);
|
|
|
|
|
|
|
|
// ... (Iterate over all frames).
|
|
|
|
WebPIterator iter;
|
|
|
|
if (WebPDemuxGetFrame(demux, 1, &iter)) {
|
|
|
|
do {
|
|
|
|
// ... (Consume 'iter'; e.g. Decode 'iter.fragment' with WebPDecode(),
|
|
|
|
// ... and get other frame properties like width, height, offsets etc.
|
|
|
|
// ... see 'struct WebPIterator' below for more info).
|
|
|
|
} while (WebPDemuxNextFrame(&iter));
|
|
|
|
WebPDemuxReleaseIterator(&iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ... (Extract metadata).
|
|
|
|
WebPChunkIterator chunk_iter;
|
|
|
|
if (flags & ICCP_FLAG) WebPDemuxGetChunk(demux, "ICCP", 1, &chunk_iter);
|
|
|
|
// ... (Consume the ICC profile in 'chunk_iter.chunk').
|
2013-02-23 00:13:10 +01:00
|
|
|
WebPDemuxReleaseChunkIterator(&chunk_iter);
|
2013-02-22 01:56:48 +01:00
|
|
|
if (flags & EXIF_FLAG) WebPDemuxGetChunk(demux, "EXIF", 1, &chunk_iter);
|
|
|
|
// ... (Consume the EXIF metadata in 'chunk_iter.chunk').
|
2013-02-23 00:13:10 +01:00
|
|
|
WebPDemuxReleaseChunkIterator(&chunk_iter);
|
2013-02-22 01:56:48 +01:00
|
|
|
if (flags & XMP_FLAG) WebPDemuxGetChunk(demux, "XMP ", 1, &chunk_iter);
|
|
|
|
// ... (Consume the XMP metadata in 'chunk_iter.chunk').
|
|
|
|
WebPDemuxReleaseChunkIterator(&chunk_iter);
|
|
|
|
WebPDemuxDelete(demux);
|
|
|
|
|
|
|
|
|
|
|
|
For a detailed Demux API reference, please refer to the header file
|
|
|
|
(src/webp/demux.h).
|
|
|
|
|
2011-09-30 07:19:26 +02:00
|
|
|
|
|
|
|
Bugs:
|
|
|
|
=====
|
|
|
|
|
|
|
|
Please report all bugs to our issue tracker:
|
|
|
|
http://code.google.com/p/webp/issues
|
|
|
|
Patches welcome! See this page to get started:
|
|
|
|
http://www.webmproject.org/code/contribute/submitting-patches/
|
|
|
|
|
|
|
|
Discuss:
|
|
|
|
========
|
|
|
|
|
|
|
|
Email: webp-discuss@webmproject.org
|
|
|
|
Web: http://groups.google.com/a/webmproject.org/group/webp-discuss
|