PHP | Imagick negateImage() Function
The 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.
Syntax:
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 then 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 program illustrates the Imagick::negateImage() function in PHP:
Program:
<?php // Create an imagick object $imagick = new Imagick( // Use negateImage function $imagick->negateImage('true'); header("Content-Type: image/jpg"); // Display the output image echo $imagick->getImageBlob(); ?> |
Output:

Related Articles:
Reference: http://php.net/manual/en/imagick.negateimage.php
Recommended Posts:
- PHP | Imagick setImageDepth() Function
- PHP | Imagick getImagePage() Function
- PHP | Imagick getImageColors() Function
- PHP | Imagick getImageColorspace() Function
- PHP | Imagick getImageGamma() Function
- PHP | Imagick getImageFormat() Function
- PHP | Imagick getImageDepth() Function
- PHP | Imagick shadeImage() Function
- PHP | Imagick vignetteImage() Function
- PHP | Imagick getImageGeometry() Function
- PHP | Imagick adaptiveSharpenImage() Function
- PHP | Imagick flattenImages() Function
- PHP | Imagick gammaImage() Function
- PHP | Imagick convolveImage() Function
- PHP | Imagick cropImage() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



