Open In App

PHP Imagick negateImage() Function

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. 

Syntax:



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

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

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: 

Example: 




<?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

Article Tags :