2011-09-30 07:19:26 +02:00
|
|
|
__ __ ____ ____ ____ __ __ _ __ __
|
|
|
|
/ \\/ \/ _ \/ _ \/ _ \/ \ \/ \___/_ / _\
|
|
|
|
\ / __/ _ \ __/ / / (_/ /__
|
2019-01-15 04:57:05 +01:00
|
|
|
\__\__/\_____/_____/__/ \__//_/\_____/__/___/v1.0.2
|
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
|
add a "-duration duration,start,end" option to webpmux
this will force a constant duration for an interval of frames
in an animation.
Notes:
a) '-duration [...]' can be repeated as many times as needed.
b) intervals are taken into account in option order. If they overlap, values will be overwritten.
c) 'start' and 'end' can be omitted, but not the duration value.
d) 'end' can be equal to '0', in which case it means 'last frame'
e) single-image files are untouched (ie. not turned into an animation file).
Some example usage:
webpmux -duration 150 in.webp -o out.webp
webpmux -duration 33,10,0 in.webp -o out.webp
webpmux -duration 200,2 -duration 150,0,50 in.webp -o out.webp
Change-Id: I9b595dafa77f9221bacd080be7858b1457f54636
2016-10-21 15:14:45 +02:00
|
|
|
webpmux -duration DURATION_OPTIONS [-duration ...]
|
|
|
|
INPUT -o OUTPUT
|
2012-01-24 21:46:46 +01:00
|
|
|
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
|
2017-12-01 09:21:13 +01:00
|
|
|
webpmux argument_file_name
|
2011-09-30 07:19:26 +02:00
|
|
|
|
|
|
|
GET_OPTIONS:
|
2014-06-18 16:45:34 +02:00
|
|
|
Extract relevant data:
|
|
|
|
icc get ICC profile
|
|
|
|
exif get EXIF metadata
|
|
|
|
xmp get XMP metadata
|
|
|
|
frame n get nth frame
|
2011-09-30 07:19:26 +02:00
|
|
|
|
|
|
|
SET_OPTIONS:
|
2014-06-18 16:45:34 +02:00
|
|
|
Set color profile/metadata:
|
|
|
|
icc file.icc set ICC profile
|
|
|
|
exif file.exif set EXIF metadata
|
|
|
|
xmp file.xmp set XMP metadata
|
2012-11-01 00:30:41 +01:00
|
|
|
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
|
|
|
|
add a "-duration duration,start,end" option to webpmux
this will force a constant duration for an interval of frames
in an animation.
Notes:
a) '-duration [...]' can be repeated as many times as needed.
b) intervals are taken into account in option order. If they overlap, values will be overwritten.
c) 'start' and 'end' can be omitted, but not the duration value.
d) 'end' can be equal to '0', in which case it means 'last frame'
e) single-image files are untouched (ie. not turned into an animation file).
Some example usage:
webpmux -duration 150 in.webp -o out.webp
webpmux -duration 33,10,0 in.webp -o out.webp
webpmux -duration 200,2 -duration 150,0,50 in.webp -o out.webp
Change-Id: I9b595dafa77f9221bacd080be7858b1457f54636
2016-10-21 15:14:45 +02:00
|
|
|
DURATION_OPTIONS:
|
2016-11-10 08:26:01 +01:00
|
|
|
Set duration of selected frames:
|
|
|
|
duration set duration for each frames
|
|
|
|
duration,frame set duration of a particular frame
|
|
|
|
duration,start,end set duration of frames in the
|
|
|
|
interval [start,end])
|
|
|
|
where: 'duration' is the duration in milliseconds
|
|
|
|
'start' is the start frame index
|
|
|
|
'end' is the inclusive end frame index
|
|
|
|
The special 'end' value '0' means: last frame.
|
add a "-duration duration,start,end" option to webpmux
this will force a constant duration for an interval of frames
in an animation.
Notes:
a) '-duration [...]' can be repeated as many times as needed.
b) intervals are taken into account in option order. If they overlap, values will be overwritten.
c) 'start' and 'end' can be omitted, but not the duration value.
d) 'end' can be equal to '0', in which case it means 'last frame'
e) single-image files are untouched (ie. not turned into an animation file).
Some example usage:
webpmux -duration 150 in.webp -o out.webp
webpmux -duration 33,10,0 in.webp -o out.webp
webpmux -duration 200,2 -duration 150,0,50 in.webp -o out.webp
Change-Id: I9b595dafa77f9221bacd080be7858b1457f54636
2016-10-21 15:14:45 +02:00
|
|
|
|
2011-09-30 07:19:26 +02:00
|
|
|
STRIP_OPTIONS:
|
2014-06-18 16:45:34 +02:00
|
|
|
Strip color profile/metadata:
|
|
|
|
icc strip ICC profile
|
|
|
|
exif strip EXIF metadata
|
|
|
|
xmp strip XMP metadata
|
2011-09-30 07:19:26 +02:00
|
|
|
|
|
|
|
FRAME_OPTIONS(i):
|
2014-06-18 16:45:34 +02:00
|
|
|
Create animation:
|
2013-08-27 03:04:52 +02:00
|
|
|
file_i +di+[xi+yi[+mi[bi]]]
|
2012-11-01 00:30:41 +01:00
|
|
|
where: 'file_i' is the i'th animation frame (WebP format),
|
2014-06-18 16:45:34 +02:00
|
|
|
'di' is the pause duration before next frame,
|
|
|
|
'xi','yi' specify the image offset for this frame,
|
|
|
|
'mi' is the dispose method for this frame (0 or 1),
|
|
|
|
'bi' is the blending method for this frame (+b or -b)
|
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
|
2014-06-18 16:45:34 +02:00
|
|
|
[Default: 255,255,255,255]
|
2012-11-01 23:34:46 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
2017-12-01 09:21:13 +01:00
|
|
|
Note: if a single file name is passed as the argument, the arguments will be
|
|
|
|
tokenized from this file. The file name must not start with the character '-'.
|
|
|
|
|
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
|
|
|
|
2015-01-13 00:48:18 +01:00
|
|
|
Code example: Demuxing WebP data to extract all the frames, ICC profile
|
2013-02-22 01:56:48 +01:00
|
|
|
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).
|
|
|
|
|
2015-01-13 00:48:18 +01:00
|
|
|
AnimEncoder API:
|
|
|
|
================
|
|
|
|
The AnimEncoder API can be used to create animated WebP images.
|
|
|
|
|
|
|
|
Code example:
|
|
|
|
|
|
|
|
WebPAnimEncoderOptions enc_options;
|
|
|
|
WebPAnimEncoderOptionsInit(&enc_options);
|
|
|
|
// ... (Tune 'enc_options' as needed).
|
|
|
|
WebPAnimEncoder* enc = WebPAnimEncoderNew(width, height, &enc_options);
|
|
|
|
while(<there are more frames>) {
|
|
|
|
WebPConfig config;
|
|
|
|
WebPConfigInit(&config);
|
|
|
|
// ... (Tune 'config' as needed).
|
|
|
|
WebPAnimEncoderAdd(enc, frame, duration, &config);
|
|
|
|
}
|
|
|
|
WebPAnimEncoderAssemble(enc, webp_data);
|
|
|
|
WebPAnimEncoderDelete(enc);
|
|
|
|
// ... (Write the 'webp_data' to a file, or re-mux it further).
|
|
|
|
|
|
|
|
|
|
|
|
For a detailed AnimEncoder API reference, please refer to the header file
|
|
|
|
(src/webp/mux.h).
|
|
|
|
|
2018-11-07 03:47:38 +01:00
|
|
|
AnimDecoder API:
|
|
|
|
================
|
|
|
|
This AnimDecoder API allows decoding (possibly) animated WebP images.
|
|
|
|
|
|
|
|
Code Example:
|
|
|
|
|
|
|
|
WebPAnimDecoderOptions dec_options;
|
|
|
|
WebPAnimDecoderOptionsInit(&dec_options);
|
|
|
|
// Tune 'dec_options' as needed.
|
|
|
|
WebPAnimDecoder* dec = WebPAnimDecoderNew(webp_data, &dec_options);
|
|
|
|
WebPAnimInfo anim_info;
|
|
|
|
WebPAnimDecoderGetInfo(dec, &anim_info);
|
|
|
|
for (uint32_t i = 0; i < anim_info.loop_count; ++i) {
|
|
|
|
while (WebPAnimDecoderHasMoreFrames(dec)) {
|
|
|
|
uint8_t* buf;
|
|
|
|
int timestamp;
|
|
|
|
WebPAnimDecoderGetNext(dec, &buf, ×tamp);
|
|
|
|
// ... (Render 'buf' based on 'timestamp').
|
|
|
|
// ... (Do NOT free 'buf', as it is owned by 'dec').
|
|
|
|
}
|
|
|
|
WebPAnimDecoderReset(dec);
|
|
|
|
}
|
|
|
|
const WebPDemuxer* demuxer = WebPAnimDecoderGetDemuxer(dec);
|
|
|
|
// ... (Do something using 'demuxer'; e.g. get EXIF/XMP/ICC data).
|
|
|
|
WebPAnimDecoderDelete(dec);
|
|
|
|
|
|
|
|
For a detailed AnimDecoder API reference, please refer to the header file
|
|
|
|
(src/webp/demux.h).
|
|
|
|
|
2011-09-30 07:19:26 +02:00
|
|
|
|
|
|
|
Bugs:
|
|
|
|
=====
|
|
|
|
|
2016-06-23 22:53:15 +02:00
|
|
|
Please report all bugs to the issue tracker:
|
2015-10-20 05:06:50 +02:00
|
|
|
https://bugs.chromium.org/p/webp
|
2011-09-30 07:19:26 +02:00
|
|
|
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
|