Open In App
Related Articles

PHP Imagick negateImage() Function

Improve Article
Save Article
Like Article

PHP Imagick::negateImage() function is an inbuilt function in PHP which is used to negates the colors in the reference image. The Grayscale option means that only grayscale values within the image are negated. 


bool Imagick::negateImage( $gray, $channel )

Parameters: This function accepts two parameters as mentioned above and described below:

  • $gray: This parameter is used to set only negate grayscale pixels within the image.
  • $channel: This parameter provides the channel constant that is valid for channel mode. More than one channel can be combined using bitwise operator. The defaults channel in Imagick function is Imagick::CHANNEL_DEFAULT.

Return Value: This function returns True on success. 

Errors/Exceptions: This function throws ImagickException on error. 

Below example illustrates the Imagick::negateImage() function in PHP: 



// Create an imagick object
$imagick = new Imagick(
// Use negateImage function
header("Content-Type: image/jpg");
// Display the output image
echo $imagick->getImageBlob();


negate image

Related Articles:


Last Updated : 03 Apr, 2023
Like Article
Save Article
Similar Reads
Related Tutorials