The normalize() function is an inbuilt function in Nodejs | Jimp which normalizes the colors of an image by computing a histogram.
Syntax:
normalize(cb)
Parameter:
- cb – This is an optional parameter that is invoked when compilation is complete.
Input Images:


Setup Environment :
npm init -y
Install Dependencies :
npm install jimp
Example 1: In this example, we will see the use of normalize().
javascript
const Jimp = require( 'jimp' );
async function main() {
const image = await Jimp.read
image.normalize()
.write( 'normalize1.png' );
}
main();
console.log( "Image Processing Completed" );
|
Output:

Example 2: With mode and cb (optional parameters)
javascript
const Jimp = require( 'jimp' );
async function main() {
const image = await Jimp.read
image.normalize( function (err) {
if (err) throw err;
})
.write( 'normalize2.png' );
}
main();
console.log( "Image Processing Completed" );
|
Output:

Reference: https://www.npmjs.com/package/jimp