# How to spin the hue of an image using Jimp in NodeJS?

Node.jsServer Side ProgrammingProgramming

NodeJS – spin modifier is an inbuilt function that is used to spin the hue of an image to a given amount from -360° to 360°. We can spin the color from 0 to 360, but it will not perform any function, as it sets the hue back to what it was before.

## Syntax

image.color([
{apply: 'spin', params: [value] }
]);

## color() paramters

• value – It will store the amount of hue to be applied while spinning. Its possible values are from -360 to 360.

## Using Node JIMP – COLOR – SPIN

Before proceeding to use color() – spin 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 a colorSpin.js file and copy-paste the following code snippet in it.

• Use node colorSpin.js to run the code.

Note − Note that 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 colorSpin() {
('/home/jimp/tutorials_point_img.jpg');
image.color([{apply: 'spin', params: [50]}])
.write('/home/jimp/colorSpin.jpg');
}

colorSpin(); // Calling the function here using async
console.log("Image is processed successfully");

## Using Node JIMP – Color - SPIN with 'cb' parameters

### Example

const Jimp = require('jimp') ;

async function colorSpin() {
('/home/jimp/tutorials_point_img.jpg');
image.color([{apply:'spin', params: [100]}], function(err){
if (err) throw err;
})
.write('/home/jimp/colorSpin.jpg');
}

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

### Output

Updated on 27-Apr-2021 13:10:22