Node.js GM whiteThreshold() Function
Last Updated :
29 Mar, 2023
The whiteThreshold() function is an inbuilt function in the GraphicsMagick library which is used to force all pixels above the threshold into white while leaving all pixels below the threshold unchanged. The function returns the true value of success.
Syntax:
whiteThreshold( intensity )
whiteThreshold( red, green, blue, opacity )
Parameters: This function accepts parameters in two fashions which are mentioned above and described below:
- intensity/red: If only a single parameter is mentioned, then this parameter is taken as intensity by the function otherwise it is taken as red intensity.
- green: This parameter is used to specify the green intensity.
- Blue: This parameter is used to specify the blue intensity.
- opacity: This parameter is used to specify the opacity intensity.
Return Value: This function returns the GraphicsMagick object.
Original Image:
Example 1: Passing only a single parameter which is taken as an intensity value.
javascript
const gm = require( 'gm' );
.whiteThreshold(.2)
.write("whiteThreshold1.png", function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Example 2: Mentioning red, blue, and green intensity.
javascript
const gm = require( 'gm' );
.whiteThreshold(.0001, 0.00001, 12, 0.11)
.write(& quot; whiteThreshold2.png & quot;, function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Reference:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...