- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to invert the colors of an image in Node Jimp?
NodeJS – Invert() is an inbuilt function that is used to invert the image colors.
Syntax
invert(cb)
sepia() paramters
b – This is an optional parameter that can be invoked after the compilation is complete.
Input Image
Using Node JIMP – INVERT()
Before proceeding to use invert() functions, please check that the following statements are already executed for setting up the environment.
npm init -y // Initialising the Node environment
npm install jimp --save // Installing the jimp dependency
Create an invert.js file and copy-paste the following code snippet in it.
Use node invert.js to run the code.
Note − The method name should match with the JS file name. Only then it will be able to call the desired method.
Example
const Jimp = require('jimp') ; async function invert() { // Reading Image const image= await Jimp.read ('/home/jimp/tutorials_point_img.jpg'); image.invert() .write('/home/jimp/invert.jpg') } invert(); // Calling the function here using async console.log("Image is processed successfully");
Output
Using Node JIMP – Sepia() with 'cb' parameters
Example
const Jimp = require('jimp') ; async function invert() { // Reading Image const image = await Jimp.read ('/home/jimp/tutorials_point_img.jpg'); image.invert(function(err){ if (err) throw err; }) .write('/home/jimp/invert.jpg'); } invert(); console.log("Image is processed successfully");
Output
- Related Articles
- How to flip an image in Node Jimp?
- How to resize an image in Node Jimp?
- How to rotate an image in Node Jimp?
- How to change the opacity of an image in Node Jimp?
- How to change an image to greyscale in Node Jimp?
- How to apply Posterize to an image in Node Jimp?
- How to overlay an image over another in Node Jimp?
- How to blur an image using Node Jimp blur() function?
- How to crop an image using crop() function in Node Jimp?
- How to apply a Sepia tone to an image in Node Jimp?
- PyTorch – How to invert the colors of an image randomly with a given probability?
- How to adjust the contrast of an image using contrast() function in Node Jimp?
- How to Invert the color of an image using JavaFX?
- How to spin the hue of an image using Jimp in NodeJS?
- How to overlay text on an image using JIMP in NodeJS?

Advertisements