+

PHP Imagick randomThresholdImage () function

Syntax:
bool Imagick::randomThresholdImage ($low, $high, $channel)
Parameters:This function takes three parameters as above and described below:
  • $low:This parameter stores the low point value.
  • $high:this parameter stores the high point value.
  • $channel:This parameter provides a channel constant that is valid for channel mode. More than one channel can be combined using the bitwise operator. The default channel in the Imagick function is Imagick::CHANNEL_DEFAULT.
Return value:This function returns True on success.Original image:
The following programs illustrate the Imagick function: randomThresholdImage()in PHP:
Program 1: < table border = "0" cellpadding = "0" cellspacing = "0">  
// require_once (` path / vendor / autoload.php ` ); header ( `Content-type: image / png` );  
// Create Imagick object $image = new Imagick ( ` https://media.engineerforengineer.org/wp-content/uploads/engineerforengineer-19.png ` ) ;  
// Use the randomThresholdImage function $image -> randomThresholdImage (0.3, 0.5, 5);  
// Show image echo $image ; ?>
Output: Program 2: $string = "Computer Science portal for Geeks!" ;  
// Create a new image of the above line // and add color and background $im = new Imagick(); $draw = new ImagickDraw();  
// Fill the color in the image $draw -> setFillColor ( new ImagickPixel ( `green` ));  
// Set the text font size $draw -> setFontSize (50); $metrix = $im -> queryFontMetrics ( $draw , $string ); $draw -> annotation (0, 40, $string ); $im -> newImage ( $metrix [ `textWidth` ], $metrix [ `textHeight` ], new ImagickPixel ( `white` ));  
// Draw image $im -> drawImage ( $draw );  
// Use the randomThresholdImage function $im -> randomThresholdImage (0.3, 0.5, 5); $im -> setImageFormat ( ` jpeg` ); header ( " Content-Type: image / jpg " );  
// Display the output image echo $im -> getImageBlob(); ?>
Output: Link : http://php.net/manual/en/imagick.randomthresholdimage.php
Get Solution for free from DataCamp guru