+

PHP ImagickvaluImage () function

Syntax:
bool Imagick::evaluateImage ($evaluation_op, $constant, $channel = Imagick::CHANNEL_DEFAULT)
Parameters:This function takes three parameters as above and described below:
  • $valuation_op:contains a valuation statement like like addition, subtraction, division, mod, etc.
  • $constant:contains the value of the operator with a score.
  • $channel: provides any channel constant suitable for the desired channel mode.
Return Value:Returns a boolean value true if the function succeeds, otherwise returns false .Below are programs illustrating the Imagick::valuImage() function in PHP:Program 1:  
// Create an Imagick object $imagick = new Imagick ( ` https://media.engineerforengineer.org/wp-content/uploads/engineerforengineer-9.png ` );  
// Declare and initialize the variable value $evaluation_op = Imagick::EVALUATE_DIVIDE; $constant = 3; $channel = Imagick::CHANNEL_ALPHA;  
// Use the valuImage function $imagick -> evaluateImage ( $evaluation_op , $constant , $channel ); header ( " Content-Type: image / jpg " );  
// Display the output image echo $imagick -> getImageBlob();  
?>
Output: Program 2:  
// Create new Imagick object $image = new Imagick (__ DIR__. `sample.png` );  
// Set the alpha channel to opaque to make it easier to work with opaque $image -> setImageAlphaChannel (Imagick::ALPHACHANNEL_OPAQUE);  
// Set parameter values ​​ $evaluation_op = Imagick::EVALUATE_DIVIDE; $constant = 3; $channel = Imagick::CHANNEL_ALPHA;  
// Call the function with parameters $image -> evaluateImage ( $evaluation_op , $constant , $channel ); header ( ` Content-type: image / jpeg` );  
// Write a new image to the specified directory $image -> writeImage (__ DIR__. `sample_with_33perc_opacity.png ` );  
?>
Output: Program 3:  
// Definition functions function Evaluate_Image ( $image , $evaluation_op , $constant , $channel ) { $image -> evaluateImage ( $eva luation_op , $constant , $channel ); return $image ; }  
// Set parameter values ​​ $final_image = Evaluate_Image ( new Imagick (__ DIR__. `sample.png` ), Imagick::EVALUATE_MEAN, 3, Imagick::CHANNEL_BLUE ); header ( ` Content-type: image / jpeg` );  
// Display the output image echo $final_image -> getImageBlob();  
?>
Output: Link: https://www.php.net/manual/en/imagick.evaluateimage.php
Please comment if you find something wrong or want to add more information. Happy coding!
Get Solution for free from DataCamp guru