dwebp-bin
WebP is a modern image format that provides superior lossless and lossy compression for images on the web. Using WebP, webmasters and web developers can create smaller, richer images that make the web faster.
Install
$ npm install dwebp-bin
WebP requires following libraries on Linux. See detail.
$ sudo apt-get install libjpeg-dev libpng-dev libtiff-dev libgif-dev
Usage
import {execFile} from 'node:child_process';
import dwebp from 'dwebp-bin';
execFile(dwebp, ['input.webp', '-o', 'output.png'], error => {
if (error) {
throw error;
}
console.log('Image is converted!');
});
CLI
$ npm install --global dwebp-bin
$ dwebp input.webp -o output.png