Wednesday, July 3, 2024
HomeLanguagesPhpPHP Imagick negateImage() Function

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:

  • $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: 

Example: 

php




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

negate image

Related Articles:

Reference: http://php.net/manual/en/imagick.negateimage.php

Nicole Veronica Rubhabha
Nicole Veronica Rubhabha
A highly competent and organized individual DotNet developer with a track record of architecting and developing web client-server applications. Recognized as a personable, dedicated performer who demonstrates innovation, communication, and teamwork to ensure quality and timely project completion. Expertise in C#, ASP.Net, MVC, LINQ, EF 6, Web Services, SQL Server, MySql, Web development,
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments