Blame README

Packit 9c6abc
          __   __  ____  ____  ____
Packit 9c6abc
         /  \\/  \/  _ \/  _ )/  _ \
Packit 9c6abc
         \       /   __/  _  \   __/
Packit 9c6abc
          \__\__/\____/\_____/__/ ____  ___
Packit 9c6abc
                / _/ /    \    \ /  _ \/ _/
Packit 9c6abc
               /  \_/   / /   \ \   __/  \__
Packit 9c6abc
               \____/____/\_____/_____/____/v1.0.0
Packit 9c6abc
Packit 9c6abc
Description:
Packit 9c6abc
============
Packit 9c6abc
Packit 9c6abc
WebP codec: library to encode and decode images in WebP format. This package
Packit 9c6abc
contains the library that can be used in other programs to add WebP support,
Packit 9c6abc
as well as the command line tools 'cwebp' and 'dwebp'.
Packit 9c6abc
Packit 9c6abc
See http://developers.google.com/speed/webp
Packit 9c6abc
Packit 9c6abc
The latest source tree is available at
Packit 9c6abc
https://chromium.googlesource.com/webm/libwebp
Packit 9c6abc
Packit 9c6abc
It is released under the same license as the WebM project.
Packit 9c6abc
See http://www.webmproject.org/license/software/ or the
Packit 9c6abc
"COPYING" file for details. An additional intellectual
Packit 9c6abc
property rights grant can be found in the file PATENTS.
Packit 9c6abc
Packit 9c6abc
Building:
Packit 9c6abc
=========
Packit 9c6abc
Packit 9c6abc
Windows build:
Packit 9c6abc
--------------
Packit 9c6abc
Packit 9c6abc
By running:
Packit 9c6abc
Packit 9c6abc
  nmake /f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output
Packit 9c6abc
Packit 9c6abc
the directory output\release-static\(x64|x86)\bin will contain the tools
Packit 9c6abc
cwebp.exe and dwebp.exe. The directory output\release-static\(x64|x86)\lib will
Packit 9c6abc
contain the libwebp static library.
Packit 9c6abc
The target architecture (x86/x64) is detected by Makefile.vc from the Visual
Packit 9c6abc
Studio compiler (cl.exe) available in the system path.
Packit 9c6abc
Packit 9c6abc
Unix build using makefile.unix:
Packit 9c6abc
-------------------------------
Packit 9c6abc
Packit 9c6abc
On platforms with GNU tools installed (gcc and make), running
Packit 9c6abc
Packit 9c6abc
  make -f makefile.unix
Packit 9c6abc
Packit 9c6abc
will build the binaries examples/cwebp and examples/dwebp, along
Packit 9c6abc
with the static library src/libwebp.a. No system-wide installation
Packit 9c6abc
is supplied, as this is a simple alternative to the full installation
Packit 9c6abc
system based on the autoconf tools (see below).
Packit 9c6abc
Please refer to makefile.unix for additional details and customizations.
Packit 9c6abc
Packit 9c6abc
Using autoconf tools:
Packit 9c6abc
---------------------
Packit 9c6abc
Prerequisites:
Packit 9c6abc
A compiler (e.g., gcc), make, autoconf, automake, libtool.
Packit 9c6abc
On a Debian-like system the following should install everything you need for a
Packit 9c6abc
minimal build:
Packit 9c6abc
$ sudo apt-get install gcc make autoconf automake libtool
Packit 9c6abc
Packit 9c6abc
When building from git sources, you will need to run autogen.sh to generate the
Packit 9c6abc
configure script.
Packit 9c6abc
Packit 9c6abc
./configure
Packit 9c6abc
make
Packit 9c6abc
make install
Packit 9c6abc
Packit 9c6abc
should be all you need to have the following files
Packit 9c6abc
Packit 9c6abc
/usr/local/include/webp/decode.h
Packit 9c6abc
/usr/local/include/webp/encode.h
Packit 9c6abc
/usr/local/include/webp/types.h
Packit 9c6abc
/usr/local/lib/libwebp.*
Packit 9c6abc
/usr/local/bin/cwebp
Packit 9c6abc
/usr/local/bin/dwebp
Packit 9c6abc
Packit 9c6abc
installed.
Packit 9c6abc
Packit 9c6abc
Note: A decode-only library, libwebpdecoder, is available using the
Packit 9c6abc
'--enable-libwebpdecoder' flag. The encode library is built separately and can
Packit 9c6abc
be installed independently using a minor modification in the corresponding
Packit 9c6abc
Makefile.am configure files (see comments there). See './configure --help' for
Packit 9c6abc
more options.
Packit 9c6abc
Packit 9c6abc
Building for MIPS Linux:
Packit 9c6abc
------------------------
Packit 9c6abc
MIPS Linux toolchain stable available releases can be found at:
Packit 9c6abc
https://community.imgtec.com/developers/mips/tools/codescape-mips-sdk/available-releases/
Packit 9c6abc
Packit 9c6abc
# Add toolchain to PATH
Packit 9c6abc
export PATH=$PATH:/path/to/toolchain/bin
Packit 9c6abc
Packit 9c6abc
# 32-bit build for mips32r5 (p5600)
Packit 9c6abc
HOST=mips-mti-linux-gnu
Packit 9c6abc
MIPS_CFLAGS="-O3 -mips32r5 -mabi=32 -mtune=p5600 -mmsa -mfp64 \
Packit 9c6abc
  -msched-weight -mload-store-pairs -fPIE"
Packit 9c6abc
MIPS_LDFLAGS="-mips32r5 -mabi=32 -mmsa -mfp64 -pie"
Packit 9c6abc
Packit 9c6abc
# 64-bit build for mips64r6 (i6400)
Packit 9c6abc
HOST=mips-img-linux-gnu
Packit 9c6abc
MIPS_CFLAGS="-O3 -mips64r6 -mabi=64 -mtune=i6400 -mmsa -mfp64 \
Packit 9c6abc
  -msched-weight -mload-store-pairs -fPIE"
Packit 9c6abc
MIPS_LDFLAGS="-mips64r6 -mabi=64 -mmsa -mfp64 -pie"
Packit 9c6abc
Packit 9c6abc
./configure --host=${HOST} --build=`config.guess` \
Packit 9c6abc
  CC="${HOST}-gcc -EL" \
Packit 9c6abc
  CFLAGS="$MIPS_CFLAGS" \
Packit 9c6abc
  LDFLAGS="$MIPS_LDFLAGS"
Packit 9c6abc
make
Packit 9c6abc
make install
Packit 9c6abc
Packit 9c6abc
CMake:
Packit 9c6abc
------
Packit 9c6abc
With CMake, you can compile libwebp, cwebp, dwebp, gif2web, img2webp, webpinfo
Packit 9c6abc
and the JS bindings.
Packit 9c6abc
Packit 9c6abc
Prerequisites:
Packit 9c6abc
A compiler (e.g., gcc with autotools) and CMake.
Packit 9c6abc
On a Debian-like system the following should install everything you need for a
Packit 9c6abc
minimal build:
Packit 9c6abc
$ sudo apt-get install build-essential cmake
Packit 9c6abc
Packit 9c6abc
When building from git sources, you will need to run cmake to generate the
Packit 9c6abc
makefiles.
Packit 9c6abc
Packit 9c6abc
mkdir build && cd build && cmake ../
Packit 9c6abc
make
Packit 9c6abc
make install
Packit 9c6abc
Packit 9c6abc
If you also want any of the executables, you will need to enable them through
Packit 9c6abc
CMake, e.g.:
Packit 9c6abc
Packit 9c6abc
cmake -DWEBP_BUILD_CWEBP=ON -DWEBP_BUILD_DWEBP=ON ../
Packit 9c6abc
Packit 9c6abc
or through your favorite interface (like ccmake or cmake-qt-gui).
Packit 9c6abc
Packit 9c6abc
Finally, once installed, you can also use WebP in your CMake project by doing:
Packit 9c6abc
Packit 9c6abc
find_package(WebP)
Packit 9c6abc
Packit 9c6abc
which will define the CMake variables WebP_INCLUDE_DIRS and WebP_LIBRARIES.
Packit 9c6abc
Packit 9c6abc
Gradle:
Packit 9c6abc
-------
Packit 9c6abc
The support for Gradle is minimal: it only helps you compile libwebp, cwebp and
Packit 9c6abc
dwebp and webpmux_example.
Packit 9c6abc
Packit 9c6abc
Prerequisites:
Packit 9c6abc
A compiler (e.g., gcc with autotools) and gradle.
Packit 9c6abc
On a Debian-like system the following should install everything you need for a
Packit 9c6abc
minimal build:
Packit 9c6abc
$ sudo apt-get install build-essential gradle
Packit 9c6abc
Packit 9c6abc
When building from git sources, you will need to run the Gradle wrapper with the
Packit 9c6abc
appropriate target, e.g. :
Packit 9c6abc
Packit 9c6abc
./gradlew buildAllExecutables
Packit 9c6abc
Packit 9c6abc
SWIG bindings:
Packit 9c6abc
--------------
Packit 9c6abc
Packit 9c6abc
To generate language bindings from swig/libwebp.swig at least swig-1.3
Packit 9c6abc
(http://www.swig.org) is required.
Packit 9c6abc
Packit 9c6abc
Currently the following functions are mapped:
Packit 9c6abc
Decode:
Packit 9c6abc
  WebPGetDecoderVersion
Packit 9c6abc
  WebPGetInfo
Packit 9c6abc
  WebPDecodeRGBA
Packit 9c6abc
  WebPDecodeARGB
Packit 9c6abc
  WebPDecodeBGRA
Packit 9c6abc
  WebPDecodeBGR
Packit 9c6abc
  WebPDecodeRGB
Packit 9c6abc
Packit 9c6abc
Encode:
Packit 9c6abc
  WebPGetEncoderVersion
Packit 9c6abc
  WebPEncodeRGBA
Packit 9c6abc
  WebPEncodeBGRA
Packit 9c6abc
  WebPEncodeRGB
Packit 9c6abc
  WebPEncodeBGR
Packit 9c6abc
  WebPEncodeLosslessRGBA
Packit 9c6abc
  WebPEncodeLosslessBGRA
Packit 9c6abc
  WebPEncodeLosslessRGB
Packit 9c6abc
  WebPEncodeLosslessBGR
Packit 9c6abc
Packit 9c6abc
See swig/README for more detailed build instructions.
Packit 9c6abc
Packit 9c6abc
Java bindings:
Packit 9c6abc
Packit 9c6abc
To build the swig-generated JNI wrapper code at least JDK-1.5 (or equivalent)
Packit 9c6abc
is necessary for enum support. The output is intended to be a shared object /
Packit 9c6abc
DLL that can be loaded via System.loadLibrary("webp_jni").
Packit 9c6abc
Packit 9c6abc
Python bindings:
Packit 9c6abc
Packit 9c6abc
To build the swig-generated Python extension code at least Python 2.6 is
Packit 9c6abc
required. Python < 2.6 may build with some minor changes to libwebp.swig or the
Packit 9c6abc
generated code, but is untested.
Packit 9c6abc
Packit 9c6abc
Encoding tool:
Packit 9c6abc
==============
Packit 9c6abc
Packit 9c6abc
The examples/ directory contains tools for encoding (cwebp) and
Packit 9c6abc
decoding (dwebp) images.
Packit 9c6abc
Packit 9c6abc
The easiest use should look like:
Packit 9c6abc
  cwebp input.png -q 80 -o output.webp
Packit 9c6abc
which will convert the input file to a WebP file using a quality factor of 80
Packit 9c6abc
on a 0->100 scale (0 being the lowest quality, 100 being the best. Default
Packit 9c6abc
value is 75).
Packit 9c6abc
You might want to try the -lossless flag too, which will compress the source
Packit 9c6abc
(in RGBA format) without any loss. The -q quality parameter will in this case
Packit 9c6abc
control the amount of processing time spent trying to make the output file as
Packit 9c6abc
small as possible.
Packit 9c6abc
Packit 9c6abc
A longer list of options is available using the -longhelp command line flag:
Packit 9c6abc
Packit 9c6abc
> cwebp -longhelp
Packit 9c6abc
Usage:
Packit 9c6abc
 cwebp [-preset <...>] [options] in_file [-o out_file]
Packit 9c6abc
Packit 9c6abc
If input size (-s) for an image is not specified, it is
Packit 9c6abc
assumed to be a PNG, JPEG, TIFF or WebP file.
Packit 9c6abc
Packit 9c6abc
Options:
Packit 9c6abc
  -h / -help ............. short help
Packit 9c6abc
  -H / -longhelp ......... long help
Packit 9c6abc
  -q <float> ............. quality factor (0:small..100:big), default=75
Packit 9c6abc
  -alpha_q <int> ......... transparency-compression quality (0..100),
Packit 9c6abc
                           default=100
Packit 9c6abc
  -preset <string> ....... preset setting, one of:
Packit 9c6abc
                            default, photo, picture,
Packit 9c6abc
                            drawing, icon, text
Packit 9c6abc
     -preset must come first, as it overwrites other parameters
Packit 9c6abc
  -z <int> ............... activates lossless preset with given
Packit 9c6abc
                           level in [0:fast, ..., 9:slowest]
Packit 9c6abc
Packit 9c6abc
  -m <int> ............... compression method (0=fast, 6=slowest), default=4
Packit 9c6abc
  -segments <int> ........ number of segments to use (1..4), default=4
Packit 9c6abc
  -size <int> ............ target size (in bytes)
Packit 9c6abc
  -psnr <float> .......... target PSNR (in dB. typically: 42)
Packit 9c6abc
Packit 9c6abc
  -s <int> <int> ......... input size (width x height) for YUV
Packit 9c6abc
  -sns <int> ............. spatial noise shaping (0:off, 100:max), default=50
Packit 9c6abc
  -f <int> ............... filter strength (0=off..100), default=60
Packit 9c6abc
  -sharpness <int> ....... filter sharpness (0:most .. 7:least sharp), default=0
Packit 9c6abc
  -strong ................ use strong filter instead of simple (default)
Packit 9c6abc
  -nostrong .............. use simple filter instead of strong
Packit 9c6abc
  -sharp_yuv ............. use sharper (and slower) RGB->YUV conversion
Packit 9c6abc
  -partition_limit <int> . limit quality to fit the 512k limit on
Packit 9c6abc
                           the first partition (0=no degradation ... 100=full)
Packit 9c6abc
  -pass <int> ............ analysis pass number (1..10)
Packit 9c6abc
  -crop <x> <y> <w> <h> .. crop picture with the given rectangle
Packit 9c6abc
  -resize <w> <h> ........ resize picture (after any cropping)
Packit 9c6abc
  -mt .................... use multi-threading if available
Packit 9c6abc
  -low_memory ............ reduce memory usage (slower encoding)
Packit 9c6abc
  -map <int> ............. print map of extra info
Packit 9c6abc
  -print_psnr ............ prints averaged PSNR distortion
Packit 9c6abc
  -print_ssim ............ prints averaged SSIM distortion
Packit 9c6abc
  -print_lsim ............ prints local-similarity distortion
Packit 9c6abc
  -d <file.pgm> .......... dump the compressed output (PGM file)
Packit 9c6abc
  -alpha_method <int> .... transparency-compression method (0..1), default=1
Packit 9c6abc
  -alpha_filter <string> . predictive filtering for alpha plane,
Packit 9c6abc
                           one of: none, fast (default) or best
Packit 9c6abc
  -exact ................. preserve RGB values in transparent area, default=off
Packit 9c6abc
  -blend_alpha <hex> ..... blend colors against background color
Packit 9c6abc
                           expressed as RGB values written in
Packit 9c6abc
                           hexadecimal, e.g. 0xc0e0d0 for red=0xc0
Packit 9c6abc
                           green=0xe0 and blue=0xd0
Packit 9c6abc
  -noalpha ............... discard any transparency information
Packit 9c6abc
  -lossless .............. encode image losslessly, default=off
Packit 9c6abc
  -near_lossless <int> ... use near-lossless image
Packit 9c6abc
                           preprocessing (0..100=off), default=100
Packit 9c6abc
  -hint <string> ......... specify image characteristics hint,
Packit 9c6abc
                           one of: photo, picture or graph
Packit 9c6abc
Packit 9c6abc
  -metadata <string> ..... comma separated list of metadata to
Packit 9c6abc
                           copy from the input to the output if present.
Packit 9c6abc
                           Valid values: all, none (default), exif, icc, xmp
Packit 9c6abc
Packit 9c6abc
  -short ................. condense printed message
Packit 9c6abc
  -quiet ................. don't print anything
Packit 9c6abc
  -version ............... print version number and exit
Packit 9c6abc
  -noasm ................. disable all assembly optimizations
Packit 9c6abc
  -v ..................... verbose, e.g. print encoding/decoding times
Packit 9c6abc
  -progress .............. report encoding progress
Packit 9c6abc
Packit 9c6abc
Experimental Options:
Packit 9c6abc
  -jpeg_like ............. roughly match expected JPEG size
Packit 9c6abc
  -af .................... auto-adjust filter strength
Packit 9c6abc
  -pre <int> ............. pre-processing filter
Packit 9c6abc
Packit 9c6abc
The main options you might want to try in order to further tune the
Packit 9c6abc
visual quality are:
Packit 9c6abc
 -preset
Packit 9c6abc
 -sns
Packit 9c6abc
 -f
Packit 9c6abc
 -m
Packit 9c6abc
Packit 9c6abc
Namely:
Packit 9c6abc
  * 'preset' will set up a default encoding configuration targeting a
Packit 9c6abc
     particular type of input. It should appear first in the list of options,
Packit 9c6abc
     so that subsequent options can take effect on top of this preset.
Packit 9c6abc
     Default value is 'default'.
Packit 9c6abc
  * 'sns' will progressively turn on (when going from 0 to 100) some additional
Packit 9c6abc
     visual optimizations (like: segmentation map re-enforcement). This option
Packit 9c6abc
     will balance the bit allocation differently. It tries to take bits from the
Packit 9c6abc
     "easy" parts of the picture and use them in the "difficult" ones instead.
Packit 9c6abc
     Usually, raising the sns value (at fixed -q value) leads to larger files,
Packit 9c6abc
     but with better quality.
Packit 9c6abc
     Typical value is around '75'.
Packit 9c6abc
  * 'f' option directly links to the filtering strength used by the codec's
Packit 9c6abc
     in-loop processing. The higher the value, the smoother the
Packit 9c6abc
     highly-compressed area will look. This is particularly useful when aiming
Packit 9c6abc
     at very small files. Typical values are around 20-30. Note that using the
Packit 9c6abc
     option -strong/-nostrong will change the type of filtering. Use "-f 0" to
Packit 9c6abc
     turn filtering off.
Packit 9c6abc
  * 'm' controls the trade-off between encoding speed and quality. Default is 4.
Packit 9c6abc
     You can try -m 5 or -m 6 to explore more (time-consuming) encoding
Packit 9c6abc
     possibilities. A lower value will result in faster encoding at the expense
Packit 9c6abc
     of quality.
Packit 9c6abc
Packit 9c6abc
Decoding tool:
Packit 9c6abc
==============
Packit 9c6abc
Packit 9c6abc
There is a decoding sample in examples/dwebp.c which will take
Packit 9c6abc
a .webp file and decode it to a PNG image file (amongst other formats).
Packit 9c6abc
This is simply to demonstrate the use of the API. You can verify the
Packit 9c6abc
file test.webp decodes to exactly the same as test_ref.ppm by using:
Packit 9c6abc
Packit 9c6abc
 cd examples
Packit 9c6abc
 ./dwebp test.webp -ppm -o test.ppm
Packit 9c6abc
 diff test.ppm test_ref.ppm
Packit 9c6abc
Packit 9c6abc
The full list of options is available using -h:
Packit 9c6abc
Packit 9c6abc
> dwebp -h
Packit 9c6abc
Usage: dwebp in_file [options] [-o out_file]
Packit 9c6abc
Packit 9c6abc
Decodes the WebP image file to PNG format [Default]
Packit 9c6abc
Use following options to convert into alternate image formats:
Packit 9c6abc
  -pam ......... save the raw RGBA samples as a color PAM
Packit 9c6abc
  -ppm ......... save the raw RGB samples as a color PPM
Packit 9c6abc
  -bmp ......... save as uncompressed BMP format
Packit 9c6abc
  -tiff ........ save as uncompressed TIFF format
Packit 9c6abc
  -pgm ......... save the raw YUV samples as a grayscale PGM
Packit 9c6abc
                 file with IMC4 layout
Packit 9c6abc
  -yuv ......... save the raw YUV samples in flat layout
Packit 9c6abc
Packit 9c6abc
 Other options are:
Packit 9c6abc
  -version ..... print version number and exit
Packit 9c6abc
  -nofancy ..... don't use the fancy YUV420 upscaler
Packit 9c6abc
  -nofilter .... disable in-loop filtering
Packit 9c6abc
  -nodither .... disable dithering
Packit 9c6abc
  -dither <d> .. dithering strength (in 0..100)
Packit 9c6abc
  -alpha_dither  use alpha-plane dithering if needed
Packit 9c6abc
  -mt .......... use multi-threading
Packit 9c6abc
  -crop <x> <y> <w> <h> ... crop output with the given rectangle
Packit 9c6abc
  -resize <w> <h> ......... scale the output (*after* any cropping)
Packit 9c6abc
  -flip ........ flip the output vertically
Packit 9c6abc
  -alpha ....... only save the alpha plane
Packit 9c6abc
  -incremental . use incremental decoding (useful for tests)
Packit 9c6abc
  -h ........... this help message
Packit 9c6abc
  -v ........... verbose (e.g. print encoding/decoding times)
Packit 9c6abc
  -quiet ....... quiet mode, don't print anything
Packit 9c6abc
  -noasm ....... disable all assembly optimizations
Packit 9c6abc
Packit 9c6abc
WebP file analysis tool:
Packit 9c6abc
========================
Packit 9c6abc
Packit 9c6abc
'webpinfo' can be used to print out the chunk level structure and bitstream
Packit 9c6abc
header information of WebP files. It can also check if the files are of valid
Packit 9c6abc
WebP format.
Packit 9c6abc
Packit 9c6abc
Usage: webpinfo [options] in_files
Packit 9c6abc
Note: there could be multiple input files;
Packit 9c6abc
      options must come before input files.
Packit 9c6abc
Options:
Packit 9c6abc
  -version ........... Print version number and exit.
Packit 9c6abc
  -quiet ............. Do not show chunk parsing information.
Packit 9c6abc
  -diag .............. Show parsing error diagnosis.
Packit 9c6abc
  -summary ........... Show chunk stats summary.
Packit 9c6abc
  -bitstream_info .... Parse bitstream header.
Packit 9c6abc
Packit 9c6abc
Visualization tool:
Packit 9c6abc
===================
Packit 9c6abc
Packit 9c6abc
There's a little self-serve visualization tool called 'vwebp' under the
Packit 9c6abc
examples/ directory. It uses OpenGL to open a simple drawing window and show
Packit 9c6abc
a decoded WebP file. It's not yet integrated in the automake build system, but
Packit 9c6abc
you can try to manually compile it using the recommendations below.
Packit 9c6abc
Packit 9c6abc
Usage: vwebp in_file [options]
Packit 9c6abc
Packit 9c6abc
Decodes the WebP image file and visualize it using OpenGL
Packit 9c6abc
Options are:
Packit 9c6abc
  -version ..... print version number and exit
Packit 9c6abc
  -noicc ....... don't use the icc profile if present
Packit 9c6abc
  -nofancy ..... don't use the fancy YUV420 upscaler
Packit 9c6abc
  -nofilter .... disable in-loop filtering
Packit 9c6abc
  -dither <int>  dithering strength (0..100), default=50
Packit 9c6abc
  -noalphadither disable alpha plane dithering
Packit 9c6abc
  -mt .......... use multi-threading
Packit 9c6abc
  -info ........ print info
Packit 9c6abc
  -h ........... this help message
Packit 9c6abc
Packit 9c6abc
Keyboard shortcuts:
Packit 9c6abc
  'c' ................ toggle use of color profile
Packit 9c6abc
  'i' ................ overlay file information
Packit 9c6abc
  'd' ................ disable blending & disposal (debug)
Packit 9c6abc
  'q' / 'Q' / ESC .... quit
Packit 9c6abc
Packit 9c6abc
Building:
Packit 9c6abc
---------
Packit 9c6abc
Packit 9c6abc
Prerequisites:
Packit 9c6abc
1) OpenGL & OpenGL Utility Toolkit (GLUT)
Packit 9c6abc
  Linux:
Packit 9c6abc
    $ sudo apt-get install freeglut3-dev mesa-common-dev
Packit 9c6abc
  Mac + XCode:
Packit 9c6abc
    - These libraries should be available in the OpenGL / GLUT frameworks.
Packit 9c6abc
  Windows:
Packit 9c6abc
    http://freeglut.sourceforge.net/index.php#download
Packit 9c6abc
Packit 9c6abc
2) (Optional) qcms (Quick Color Management System)
Packit 9c6abc
  i. Download qcms from Mozilla / Chromium:
Packit 9c6abc
    http://hg.mozilla.org/mozilla-central/file/0e7639e3bdfb/gfx/qcms
Packit 9c6abc
    http://src.chromium.org/viewvc/chrome/trunk/src/third_party/qcms
Packit 9c6abc
  ii. Build and archive the source files as libqcms.a / qcms.lib
Packit 9c6abc
  iii. Update makefile.unix / Makefile.vc
Packit 9c6abc
    a) Define WEBP_HAVE_QCMS
Packit 9c6abc
    b) Update include / library paths to reference the qcms directory.
Packit 9c6abc
Packit 9c6abc
Build using makefile.unix / Makefile.vc:
Packit 9c6abc
$ make -f makefile.unix examples/vwebp
Packit 9c6abc
> nmake /f Makefile.vc CFG=release-static \
Packit 9c6abc
    ../obj/x64/release-static/bin/vwebp.exe
Packit 9c6abc
Packit 9c6abc
Animation creation tool:
Packit 9c6abc
========================
Packit 9c6abc
The utility 'img2webp' can turn a sequence of input images (PNG, JPEG, ...)
Packit 9c6abc
into an animated WebP file. It offers fine control over duration, encoding
Packit 9c6abc
modes, etc.
Packit 9c6abc
Packit 9c6abc
Usage:
Packit 9c6abc
Packit 9c6abc
  img2webp [file-level options] [image files...] [per-frame options...]
Packit 9c6abc
Packit 9c6abc
File-level options (only used at the start of compression):
Packit 9c6abc
 -min_size ............ minimize size
Packit 9c6abc
 -loop <int> .......... loop count (default: 0, = infinite loop)
Packit 9c6abc
 -kmax <int> .......... maximum number of frame between key-frames
Packit 9c6abc
                        (0=only keyframes)
Packit 9c6abc
 -kmin <int> .......... minimum number of frame between key-frames
Packit 9c6abc
                        (0=disable key-frames altogether)
Packit 9c6abc
 -mixed ............... use mixed lossy/lossless automatic mode
Packit 9c6abc
 -v ................... verbose mode
Packit 9c6abc
 -h ................... this help
Packit 9c6abc
 -version ............. print version number and exit
Packit 9c6abc
Packit 9c6abc
Per-frame options (only used for subsequent images input):
Packit 9c6abc
 -d <int> ............. frame duration in ms (default: 100)
Packit 9c6abc
 -lossless  ........... use lossless mode (default)
Packit 9c6abc
 -lossy ... ........... use lossy mode
Packit 9c6abc
 -q <float> ........... quality
Packit 9c6abc
 -m <int> ............. method to use
Packit 9c6abc
Packit 9c6abc
example: img2webp -loop 2 in0.png -lossy in1.jpg
Packit 9c6abc
                  -d 80 in2.tiff -o out.webp
Packit 9c6abc
Packit 9c6abc
Animated GIF conversion:
Packit 9c6abc
========================
Packit 9c6abc
Animated GIF files can be converted to WebP files with animation using the
Packit 9c6abc
gif2webp utility available under examples/. The files can then be viewed using
Packit 9c6abc
vwebp.
Packit 9c6abc
Packit 9c6abc
Usage:
Packit 9c6abc
 gif2webp [options] gif_file -o webp_file
Packit 9c6abc
Options:
Packit 9c6abc
  -h / -help ............. this help
Packit 9c6abc
  -lossy ................. encode image using lossy compression
Packit 9c6abc
  -mixed ................. for each frame in the image, pick lossy
Packit 9c6abc
                           or lossless compression heuristically
Packit 9c6abc
  -q <float> ............. quality factor (0:small..100:big)
Packit 9c6abc
  -m <int> ............... compression method (0=fast, 6=slowest)
Packit 9c6abc
  -min_size .............. minimize output size (default:off)
Packit 9c6abc
                           lossless compression by default; can be
Packit 9c6abc
                           combined with -q, -m, -lossy or -mixed
Packit 9c6abc
                           options
Packit 9c6abc
  -kmin <int> ............ min distance between key frames
Packit 9c6abc
  -kmax <int> ............ max distance between key frames
Packit 9c6abc
  -f <int> ............... filter strength (0=off..100)
Packit 9c6abc
  -metadata <string> ..... comma separated list of metadata to
Packit 9c6abc
                           copy from the input to the output if present
Packit 9c6abc
                           Valid values: all, none, icc, xmp (default)
Packit 9c6abc
  -loop_compatibility .... use compatibility mode for Chrome
Packit 9c6abc
                           version prior to M62 (inclusive)
Packit 9c6abc
  -mt .................... use multi-threading if available
Packit 9c6abc
Packit 9c6abc
  -version ............... print version number and exit
Packit 9c6abc
  -v ..................... verbose
Packit 9c6abc
  -quiet ................. don't print anything
Packit 9c6abc
Packit 9c6abc
Building:
Packit 9c6abc
---------
Packit 9c6abc
With the libgif development files installed, gif2webp can be built using
Packit 9c6abc
makefile.unix:
Packit 9c6abc
$ make -f makefile.unix examples/gif2webp
Packit 9c6abc
Packit 9c6abc
or using autoconf:
Packit 9c6abc
$ ./configure --enable-everything
Packit 9c6abc
$ make
Packit 9c6abc
Packit 9c6abc
Comparison of animated images:
Packit 9c6abc
==============================
Packit 9c6abc
Test utility anim_diff under examples/ can be used to compare two animated
Packit 9c6abc
images (each can be GIF or WebP).
Packit 9c6abc
Packit 9c6abc
Usage: anim_diff <image1> <image2> [options]
Packit 9c6abc
Packit 9c6abc
Options:
Packit 9c6abc
  -dump_frames <folder> dump decoded frames in PAM format
Packit 9c6abc
  -min_psnr <float> ... minimum per-frame PSNR
Packit 9c6abc
  -raw_comparison ..... if this flag is not used, RGB is
Packit 9c6abc
                        premultiplied before comparison
Packit 9c6abc
  -max_diff <int> ..... maximum allowed difference per channel
Packit 9c6abc
                        between corresponding pixels in subsequent
Packit 9c6abc
                        frames
Packit 9c6abc
  -h .................. this help
Packit 9c6abc
  -version ............ print version number and exit
Packit 9c6abc
Packit 9c6abc
Building:
Packit 9c6abc
---------
Packit 9c6abc
With the libgif development files and a C++ compiler installed, anim_diff can
Packit 9c6abc
be built using makefile.unix:
Packit 9c6abc
$ make -f makefile.unix examples/anim_diff
Packit 9c6abc
Packit 9c6abc
or using autoconf:
Packit 9c6abc
$ ./configure --enable-everything
Packit 9c6abc
$ make
Packit 9c6abc
Packit 9c6abc
Encoding API:
Packit 9c6abc
=============
Packit 9c6abc
Packit 9c6abc
The main encoding functions are available in the header src/webp/encode.h
Packit 9c6abc
The ready-to-use ones are:
Packit 9c6abc
size_t WebPEncodeRGB(const uint8_t* rgb, int width, int height, int stride,
Packit 9c6abc
                     float quality_factor, uint8_t** output);
Packit 9c6abc
size_t WebPEncodeBGR(const uint8_t* bgr, int width, int height, int stride,
Packit 9c6abc
                     float quality_factor, uint8_t** output);
Packit 9c6abc
size_t WebPEncodeRGBA(const uint8_t* rgba, int width, int height, int stride,
Packit 9c6abc
                      float quality_factor, uint8_t** output);
Packit 9c6abc
size_t WebPEncodeBGRA(const uint8_t* bgra, int width, int height, int stride,
Packit 9c6abc
                      float quality_factor, uint8_t** output);
Packit 9c6abc
Packit 9c6abc
They will convert raw RGB samples to a WebP data. The only control supplied
Packit 9c6abc
is the quality factor.
Packit 9c6abc
Packit 9c6abc
There are some variants for using the lossless format:
Packit 9c6abc
Packit 9c6abc
size_t WebPEncodeLosslessRGB(const uint8_t* rgb, int width, int height,
Packit 9c6abc
                             int stride, uint8_t** output);
Packit 9c6abc
size_t WebPEncodeLosslessBGR(const uint8_t* bgr, int width, int height,
Packit 9c6abc
                             int stride, uint8_t** output);
Packit 9c6abc
size_t WebPEncodeLosslessRGBA(const uint8_t* rgba, int width, int height,
Packit 9c6abc
                              int stride, uint8_t** output);
Packit 9c6abc
size_t WebPEncodeLosslessBGRA(const uint8_t* bgra, int width, int height,
Packit 9c6abc
                              int stride, uint8_t** output);
Packit 9c6abc
Packit 9c6abc
Of course in this case, no quality factor is needed since the compression
Packit 9c6abc
occurs without loss of the input values, at the expense of larger output sizes.
Packit 9c6abc
Packit 9c6abc
Advanced encoding API:
Packit 9c6abc
----------------------
Packit 9c6abc
Packit 9c6abc
A more advanced API is based on the WebPConfig and WebPPicture structures.
Packit 9c6abc
Packit 9c6abc
WebPConfig contains the encoding settings and is not tied to a particular
Packit 9c6abc
picture.
Packit 9c6abc
WebPPicture contains input data, on which some WebPConfig will be used for
Packit 9c6abc
compression.
Packit 9c6abc
The encoding flow looks like:
Packit 9c6abc
Packit 9c6abc
-------------------------------------- BEGIN PSEUDO EXAMPLE
Packit 9c6abc
Packit 9c6abc
#include <webp/encode.h>
Packit 9c6abc
Packit 9c6abc
  // Setup a config, starting form a preset and tuning some additional
Packit 9c6abc
  // parameters
Packit 9c6abc
  WebPConfig config;
Packit 9c6abc
  if (!WebPConfigPreset(&config, WEBP_PRESET_PHOTO, quality_factor))
Packit 9c6abc
    return 0;   // version error
Packit 9c6abc
  }
Packit 9c6abc
  // ... additional tuning
Packit 9c6abc
  config.sns_strength = 90;
Packit 9c6abc
  config.filter_sharpness = 6;
Packit 9c6abc
  config_error = WebPValidateConfig(&config);  // not mandatory, but useful
Packit 9c6abc
Packit 9c6abc
  // Setup the input data
Packit 9c6abc
  WebPPicture pic;
Packit 9c6abc
  if (!WebPPictureInit(&pic)) {
Packit 9c6abc
    return 0;  // version error
Packit 9c6abc
  }
Packit 9c6abc
  pic.width = width;
Packit 9c6abc
  pic.height = height;
Packit 9c6abc
  // allocated picture of dimension width x height
Packit 9c6abc
  if (!WebPPictureAllocate(&pic)) {
Packit 9c6abc
    return 0;   // memory error
Packit 9c6abc
  }
Packit 9c6abc
  // at this point, 'pic' has been initialized as a container,
Packit 9c6abc
  // and can receive the Y/U/V samples.
Packit 9c6abc
  // Alternatively, one could use ready-made import functions like
Packit 9c6abc
  // WebPPictureImportRGB(), which will take care of memory allocation.
Packit 9c6abc
  // In any case, past this point, one will have to call
Packit 9c6abc
  // WebPPictureFree(&pic) to reclaim memory.
Packit 9c6abc
Packit 9c6abc
  // Set up a byte-output write method. WebPMemoryWriter, for instance.
Packit 9c6abc
  WebPMemoryWriter wrt;
Packit 9c6abc
  WebPMemoryWriterInit(&wrt;;     // initialize 'wrt'
Packit 9c6abc
Packit 9c6abc
  pic.writer = MyFileWriter;
Packit 9c6abc
  pic.custom_ptr = my_opaque_structure_to_make_MyFileWriter_work;
Packit 9c6abc
Packit 9c6abc
  // Compress!
Packit 9c6abc
  int ok = WebPEncode(&config, &pic;;   // ok = 0 => error occurred!
Packit 9c6abc
  WebPPictureFree(&pic;;  // must be called independently of the 'ok' result.
Packit 9c6abc
Packit 9c6abc
  // output data should have been handled by the writer at that point.
Packit 9c6abc
  // -> compressed data is the memory buffer described by wrt.mem / wrt.size
Packit 9c6abc
Packit 9c6abc
  // deallocate the memory used by compressed data
Packit 9c6abc
  WebPMemoryWriterClear(&wrt;;
Packit 9c6abc
Packit 9c6abc
-------------------------------------- END PSEUDO EXAMPLE
Packit 9c6abc
Packit 9c6abc
Decoding API:
Packit 9c6abc
=============
Packit 9c6abc
Packit 9c6abc
This is mainly just one function to call:
Packit 9c6abc
Packit 9c6abc
#include "webp/decode.h"
Packit 9c6abc
uint8_t* WebPDecodeRGB(const uint8_t* data, size_t data_size,
Packit 9c6abc
                       int* width, int* height);
Packit 9c6abc
Packit 9c6abc
Please have a look at the file src/webp/decode.h for the details.
Packit 9c6abc
There are variants for decoding in BGR/RGBA/ARGB/BGRA order, along with
Packit 9c6abc
decoding to raw Y'CbCr samples. One can also decode the image directly into a
Packit 9c6abc
pre-allocated buffer.
Packit 9c6abc
Packit 9c6abc
To detect a WebP file and gather the picture's dimensions, the function:
Packit 9c6abc
  int WebPGetInfo(const uint8_t* data, size_t data_size,
Packit 9c6abc
                  int* width, int* height);
Packit 9c6abc
is supplied. No decoding is involved when using it.
Packit 9c6abc
Packit 9c6abc
Incremental decoding API:
Packit 9c6abc
=========================
Packit 9c6abc
Packit 9c6abc
In the case when data is being progressively transmitted, pictures can still
Packit 9c6abc
be incrementally decoded using a slightly more complicated API. Decoder state
Packit 9c6abc
is stored into an instance of the WebPIDecoder object. This object can be
Packit 9c6abc
created with the purpose of decoding either RGB or Y'CbCr samples.
Packit 9c6abc
For instance:
Packit 9c6abc
Packit 9c6abc
  WebPDecBuffer buffer;
Packit 9c6abc
  WebPInitDecBuffer(&buffer);
Packit 9c6abc
  buffer.colorspace = MODE_BGR;
Packit 9c6abc
  ...
Packit 9c6abc
  WebPIDecoder* idec = WebPINewDecoder(&buffer);
Packit 9c6abc
Packit 9c6abc
As data is made progressively available, this incremental-decoder object
Packit 9c6abc
can be used to decode the picture further. There are two (mutually exclusive)
Packit 9c6abc
ways to pass freshly arrived data:
Packit 9c6abc
Packit 9c6abc
either by appending the fresh bytes:
Packit 9c6abc
Packit 9c6abc
  WebPIAppend(idec, fresh_data, size_of_fresh_data);
Packit 9c6abc
Packit 9c6abc
or by just mentioning the new size of the transmitted data:
Packit 9c6abc
Packit 9c6abc
  WebPIUpdate(idec, buffer, size_of_transmitted_buffer);
Packit 9c6abc
Packit 9c6abc
Note that 'buffer' can be modified between each call to WebPIUpdate, in
Packit 9c6abc
particular when the buffer is resized to accommodate larger data.
Packit 9c6abc
Packit 9c6abc
These functions will return the decoding status: either VP8_STATUS_SUSPENDED if
Packit 9c6abc
decoding is not finished yet or VP8_STATUS_OK when decoding is done. Any other
Packit 9c6abc
status is an error condition.
Packit 9c6abc
Packit 9c6abc
The 'idec' object must always be released (even upon an error condition) by
Packit 9c6abc
calling: WebPDelete(idec).
Packit 9c6abc
Packit 9c6abc
To retrieve partially decoded picture samples, one must use the corresponding
Packit 9c6abc
method: WebPIDecGetRGB or WebPIDecGetYUVA.
Packit 9c6abc
It will return the last displayable pixel row.
Packit 9c6abc
Packit 9c6abc
Lastly, note that decoding can also be performed into a pre-allocated pixel
Packit 9c6abc
buffer. This buffer must be passed when creating a WebPIDecoder, calling
Packit 9c6abc
WebPINewRGB() or WebPINewYUVA().
Packit 9c6abc
Packit 9c6abc
Please have a look at the src/webp/decode.h header for further details.
Packit 9c6abc
Packit 9c6abc
Advanced Decoding API:
Packit 9c6abc
======================
Packit 9c6abc
Packit 9c6abc
WebP decoding supports an advanced API which provides on-the-fly cropping and
Packit 9c6abc
rescaling, something of great usefulness on memory-constrained environments like
Packit 9c6abc
mobile phones. Basically, the memory usage will scale with the output's size,
Packit 9c6abc
not the input's, when one only needs a quick preview or a zoomed in portion of
Packit 9c6abc
an otherwise too-large picture. Some CPU can be saved too, incidentally.
Packit 9c6abc
Packit 9c6abc
-------------------------------------- BEGIN PSEUDO EXAMPLE
Packit 9c6abc
     // A) Init a configuration object
Packit 9c6abc
     WebPDecoderConfig config;
Packit 9c6abc
     CHECK(WebPInitDecoderConfig(&config));
Packit 9c6abc
Packit 9c6abc
     // B) optional: retrieve the bitstream's features.
Packit 9c6abc
     CHECK(WebPGetFeatures(data, data_size, &config.input) == VP8_STATUS_OK);
Packit 9c6abc
Packit 9c6abc
     // C) Adjust 'config' options, if needed
Packit 9c6abc
     config.options.no_fancy_upsampling = 1;
Packit 9c6abc
     config.options.use_scaling = 1;
Packit 9c6abc
     config.options.scaled_width = scaledWidth();
Packit 9c6abc
     config.options.scaled_height = scaledHeight();
Packit 9c6abc
     // etc.
Packit 9c6abc
Packit 9c6abc
     // D) Specify 'config' output options for specifying output colorspace.
Packit 9c6abc
     // Optionally the external image decode buffer can also be specified.
Packit 9c6abc
     config.output.colorspace = MODE_BGRA;
Packit 9c6abc
     // Optionally, the config.output can be pointed to an external buffer as
Packit 9c6abc
     // well for decoding the image. This externally supplied memory buffer
Packit 9c6abc
     // should be big enough to store the decoded picture.
Packit 9c6abc
     config.output.u.RGBA.rgba = (uint8_t*) memory_buffer;
Packit 9c6abc
     config.output.u.RGBA.stride = scanline_stride;
Packit 9c6abc
     config.output.u.RGBA.size = total_size_of_the_memory_buffer;
Packit 9c6abc
     config.output.is_external_memory = 1;
Packit 9c6abc
Packit 9c6abc
     // E) Decode the WebP image. There are two variants w.r.t decoding image.
Packit 9c6abc
     // The first one (E.1) decodes the full image and the second one (E.2) is
Packit 9c6abc
     // used to incrementally decode the image using small input buffers.
Packit 9c6abc
     // Any one of these steps can be used to decode the WebP image.
Packit 9c6abc
Packit 9c6abc
     // E.1) Decode full image.
Packit 9c6abc
     CHECK(WebPDecode(data, data_size, &config) == VP8_STATUS_OK);
Packit 9c6abc
Packit 9c6abc
     // E.2) Decode image incrementally.
Packit 9c6abc
     WebPIDecoder* const idec = WebPIDecode(NULL, NULL, &config);
Packit 9c6abc
     CHECK(idec != NULL);
Packit 9c6abc
     while (bytes_remaining > 0) {
Packit 9c6abc
       VP8StatusCode status = WebPIAppend(idec, input, bytes_read);
Packit 9c6abc
       if (status == VP8_STATUS_OK || status == VP8_STATUS_SUSPENDED) {
Packit 9c6abc
         bytes_remaining -= bytes_read;
Packit 9c6abc
       } else {
Packit 9c6abc
         break;
Packit 9c6abc
       }
Packit 9c6abc
     }
Packit 9c6abc
     WebPIDelete(idec);
Packit 9c6abc
Packit 9c6abc
     // F) Decoded image is now in config.output (and config.output.u.RGBA).
Packit 9c6abc
     // It can be saved, displayed or otherwise processed.
Packit 9c6abc
Packit 9c6abc
     // G) Reclaim memory allocated in config's object. It's safe to call
Packit 9c6abc
     // this function even if the memory is external and wasn't allocated
Packit 9c6abc
     // by WebPDecode().
Packit 9c6abc
     WebPFreeDecBuffer(&config.output);
Packit 9c6abc
Packit 9c6abc
-------------------------------------- END PSEUDO EXAMPLE
Packit 9c6abc
Packit 9c6abc
Bugs:
Packit 9c6abc
=====
Packit 9c6abc
Packit 9c6abc
Please report all bugs to the issue tracker:
Packit 9c6abc
    https://bugs.chromium.org/p/webp
Packit 9c6abc
Patches welcome! See this page to get started:
Packit 9c6abc
    http://www.webmproject.org/code/contribute/submitting-patches/
Packit 9c6abc
Packit 9c6abc
Discuss:
Packit 9c6abc
========
Packit 9c6abc
Packit 9c6abc
Email: webp-discuss@webmproject.org
Packit 9c6abc
Web: http://groups.google.com/a/webmproject.org/group/webp-discuss