PHP | Imagick randomThresholdImage() Function Last Updated : 13 May, 2022 Comments Improve Suggest changes Like Article Like Report The Imagick::randomThresholdImage() function is an inbuilt function in PHP that is used to change the value of individual pixels based on the intensity of each pixel compared to the threshold. The result is a high-contrast, two-color image. Syntax: bool Imagick::randomThresholdImage( $low, $high, $channel ) Parameters: This function accepts three parameters as mentioned above and described below: $low: This parameter stores the value of the low point.$high: This parameter stores the value of the high point.$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. Original Image: Below programs illustrate Imagick::randomThresholdImage() function in PHP: Program 1: PHP <?php // require_once('path/vendor/autoload.php'); header('Content-type: image/png'); //Create Imagick Object $image = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-19.png'); // Use randomThresholdImage Function $image->randomThresholdImage(0.3, 0.5, 5); // Display the image echo $image; ?> Output: Program 2: PHP <?php $string = "Computer Science portal for Geeks!"; // Creating new image of above String // and add color and background $im = new Imagick(); $draw = new ImagickDraw(); // Fill the color in image $draw->setFillColor(new ImagickPixel('green')); // Set the text font size $draw->setFontSize(50); $matrix = $im->queryFontMetrics($draw, $string); $draw->annotation(0, 40, $string); $im->newImage($matrix['textWidth'], $matrix['textHeight'], new ImagickPixel('white')); // Draw the image $im->drawImage($draw); // Use 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: Reference: http://php.net/manual/en/imagick.randomthresholdimage.php Comment More infoAdvertise with us Next Article PHP | Imagick randomThresholdImage() Function S sarthak_ishu11 Follow Improve Article Tags : Misc Technical Scripter Web Technologies PHP Image-Processing PHP-function PHP-Imagick +3 More Practice Tags : Misc Similar Reads PHP | Imagick whiteThresholdImage Function The Imagick::whiteThresholdImage() function is an inbuilt function in PHP which is used to convert all pixels above the threshold value into white. This function force all pixels above the threshold value into white while leaving all pixels below the threshold unchanged. Syntax: bool Imagick::whiteT 1 min read PHP | Imagick readImage() Function The Imagick::readImage() function is an inbuilt function in PHP which is used to read an image from filename. Syntax: bool Imagick::readImage( string $filename ) Parameters:This function accepts a single parameter $filename which holds the name of the file. It can also accept URL of the file. Return 1 min read PHP | Imagick rollImage() Function The Imagick::rollImage() function is an inbuilt function in PHP which is used to roll an image. Syntax: bool Imagick::rollImage( $x, $y ) Parameters: This function accepts two parameters as mentioned above and described below: $x: This parameter stores the value of the X offset. $y: This parameter s 1 min read PHP | Imagick transformImage() Function The Imagick::transformImage() function is an inbuilt function in PHP which is used to crop size and the image geometry. Syntax: Imagick Imagick::transformImage( $crop, $geometry ) Parameters: This function accepts two parameters as mentioned above and described below: $crop: This parameter is used t 1 min read PHP | Imagick transposeImage() Function The Imagick::transposeImage() function is an inbuilt function in PHP which is used to create a vertical mirror image. This function creates an image by reflecting the pixels around the central x-axis while rotating them 90-degrees. Syntax: bool Imagick::transposeImage( void ) Parameters: This functi 1 min read Like