jimp
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@jimp/custom | 0.22.12 | 34.27 kB | MIT | prod peer | 1 |
@jimp/plugins | 0.22.12 | 20.4 kB | MIT | prod | 1 1 |
@jimp/types | 0.22.12 | 8.35 kB | MIT | prod | 1 |
regenerator-runtime | 0.13.11 | 8.32 kB | MIT | prod |
Jimp, or "JavaScript Image Manipulation Program", is an image processing library for Node built entirely in JavaScript. It is designed to handle various image files, including JPEG, PNG, BMP, TIFF, and GIF. It requires zero external or native dependencies making it popular for its simplicity and ease-of-use.
Jimp is used by first installing it in your project via npm with the command npm install --save jimp
. Once installed, you can require it in your JavaScript file and use it to read and manipulate images. You can resize, adjust quality, set to greyscale, and write the output to a new JPEG image.
Here is an example of its usage with callback:
var Jimp = require("jimp");
// Open a file called "lenna.png"
Jimp.read("lenna.png", (err, lenna) => {
if (err) throw err;
lenna
.resize(256, 256) // resize
.quality(60) // set JPEG quality
.greyscale() // set greyscale
.write("lena-small-bw.jpg"); // save
});
And here is an example using promises:
Jimp.read("lenna.png")
.then((lenna) => {
return lenna
.resize(256, 256) // resize
.quality(60) // set JPEG quality
.greyscale() // set greyscale
.write("lena-small-bw.jpg"); // save
})
.catch((err) => {
console.error(err);
});
If you're utilizing TypeScript, you would import the library with ES6 default import syntax:
import Jimp from "jimp";
And for those using a web bundler such as webpack, rollup, or parcel, you can benefit by utilizing the module
build of Jimp:
import Jimp from "jimp/es";
The documentation for Jimp can be found directly in the repository on GitHub. The URL is: https://github.com/jimp-dev/jimp. The readme file in this repository also contains extensive information and code examples for using the Jimp package and its associated methods and options.