Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Node.js wrapper for cwebp and dwebp binaries from WebP image processing utility.
npm install cwebp
You can get latest WebP source, pre-compiled binaries and installation instructions from its official website, or from its downloads repository.
Linux users may use this installation script to automatically download and install the latest WebP binaries:
curl -s https://raw.githubusercontent.com/Intervox/node-webp/latest/bin/install_webp | sudo bash
MacOS users may install WebP using homebrew:
brew install webp
or MacPorts:
sudo port selfupdate
sudo port install webp
If none of it suit your needs, you may build the WebP utilities yourself.
node-webp version | Fully compatible WebP versions | Partially compatible WebP versions |
---|---|---|
0.1.x | all versions | all versions |
1.x | 0.4.1 and later | all versions |
2.x | 0.5.0 and later | all versions |
var CWebp = require('cwebp').CWebp;
var DWebp = require('cwebp').DWebp;
var encoder = new CWebp(source_image);
var decoder = new DWebp(source_webp);
or
// new is optional
var encoder = CWebp(source_image);
var decoder = DWebp(source_webp);
or
// Backward-compatibility with cwebp@0.1.x
var CWebp = require('cwebp');
By default node-webp
looks for cwebp
and dwebp
binary in your $PATH
.
var Webp = require('cwebp');
var binPath = require('webp').cwebp;
var webp = new Webp(source, binPath);
var CWebp = require('cwebp').CWebp;
CWebp.bin = require('webp').cwebp;
var encoder = new CWebp(source);
var DWebp = require('cwebp').DWebp;
DWebp.bin = require('webp').dwebp;
var decoder = new DWebp(source);
N.B.: webp
npm module provide old webp 0.3.x
binaries.
When source is a string node-webp
treats it as a file path.
var CWebp = require('cwebp').CWebp;
var DWebp = require('cwebp').DWebp;
var encoder = new CWebp('original.jpeg');
var decoder = new DWebp('converted.webp');
It also accepts Buffers and Streams.
var encoder = new CWebp(buffer);
var decoder = new DWebp(stream);
Note that node-webp
will start listening to the data in a source stream
only when .write()
, .stream()
or .toBuffer()
is called.
encoder.write('image.webp', function(err) {
console.log(err || 'encoded successfully');
});
decoder.write('image.png', function(err) {
console.log(err || 'decoded successfully');
});
decoder.toBuffer(function(err, buffer) {
// ...
});
var stream = encoder.stream();
stream.pipe(destination);
stream.on('error', function(err) {
// something bad happened
});
node-webp
supports A+ promises.
encoder.write('image.webp').then(function() {
// ...
});
encoder.toBuffer().then(function(buffer) {
// ...
});
decoder.stream().then(function(stream) {
// ...
});
node-webp
uses when.js library.
node-webp
provides helper functions for most of cwebp
and dwebp
conversion options.
For the full list of available helpers see methods.json file.
encoder.quality(60);
decoder.tiff();
encoder.command('-d', 'dump.pgm');
encoder.spawnOptions({detached: true});
FAQs
node.js wrapper for cwebp and dwebp binaries from WebP image processing utility
The npm package cwebp receives a total of 2,187 weekly downloads. As such, cwebp popularity was classified as popular.
We found that cwebp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.