Image Processing with NodeJS JIMP

JIMP, also known as JavaScript Image Manipulation Program, is an image processing library for Node written in JavaScript with no other dependency. It allows the user to easily manipulate the and transform the images into any required shape, format, dimnesion or style. It can also be used for optimizing images to minimize the file size, ensuring high visualquality or reducing the bandwidth.

Using JIMP, you can resize and crop images, convert them to the format as needed and also apply different filters and affects. Following are image formats that are supported by NodeJS JIMP −

  • @jimp/jpeg

  • @jimp/png

  • @jimp/bmp

  • @jimp/tiff

  • @jimp/gif


Setup Environment -

npm init -y

Installing Dependecy -

npm install --save jimp

Using NodeJS Jimp

Jimp extends two functionalities – Callback and Promise API's for manipulating images. Here, we will use JIMP's Promise API.

The static method takes an image as an input. The input could either be a location of an Image file in the file system, a web address (URL), Jimp instance or a stream buffer.After processing it returns a promise.


// npm install --save jimp for importing jimp
const Jimp = require('jimp') ;
async function main() {
   // Reading Image
   const image = await Jimp. read
   image.blur(2, function(err){
      if (err) throw err;

console.log("Image is processed successfully");

Input - Original Image

Output – Blurred Image (blur2.jpeg)