WebP requires following libraries on Linux. See detail.
$ sudo apt-get install libjpeg-dev libpng-dev libtiff-dev libgif-dev
$ npm install --save dwebp-bin
$ dwebp input.webp -o output.png
var execFile = require('child_process').execFile;
var dwebp = require('dwebp-bin').path;
execFile(dwebp, ['input.webp', '-o', 'output.png'], function (error) {
if (error) {
throw error;
}
console.log('Image was converted');
});
Usage: dwebp in_file [options] [-o out_file]
Decodes the WebP image file to PNG format [Default]
Use following options to convert into alternate image formats:
-pam ......... save the raw RGBA samples as a color PAM
-ppm ......... save the raw RGB samples as a color PPM
-bmp ......... save as uncompressed BMP format
-tiff ........ save as uncompressed TIFF format
-pgm ......... save the raw YUV samples as a grayscale PGM
file with IMC4 layout
-yuv ......... save the raw YUV samples in flat layout
Other options are:
-version .... print version number and exit
-nofancy ..... don't use the fancy YUV420 upscaler
-nofilter .... disable in-loop filtering
-nodither .... disable dithering
-dither <d> .. dithering strength (in 0..100)
-mt .......... use multi-threading
-crop <x> <y> <w> <h> ... crop output with the given rectangle
-scale <w> <h> .......... scale the output (*after* any cropping)
-flip ........ flip the output vertically
-alpha ....... only save the alpha plane
-incremental . use incremental decoding (useful for tests)
-h ....... this help message
-v ....... verbose (e.g. print encoding/decoding times)
-noasm ....... disable all assembly optimizations
This is licensed under BSD.
WebP is licensed under Creative Commons Attribution 3.0 License.