PHP | Imagick cropImage() Function Last Updated : 06 Oct, 2021 Comments Improve Suggest changes Like Article Like Report The Imagick::cropImage() function is an inbuilt function in PHP which is used to extracts the region of the image.Syntax: int Imagick::cropImage( $width, $height, $x, $y ) Parameters: This function accept four parameters as mention above and describe below. $width: This parameter is used to specify the width of the cropped image.$height: This parameter is used to specify the height of the cropped image.$x: This parameter is used to specify the X coordinate of the cropped image of top left corner.$y: This parameter is used to specify the Y coordinate of the cropped image of top left corner. Return Value: This function returns True on success.Below programs illustrate the Imagick::cropImage() function in PHP:Original Image: Program 1: php <?php // require_once('path/vendor/autoload.php'); // Create an imagick object $image = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Imagick function to crop Image $image->cropImage(390, 100, 0, 0); header("Content-Type: image/jpg"); // Display the image echo $image->getImageBlob(); ?> Output: Original Image: 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); // Set the image format $im->setImageFormat('png'); // Imagick function to crop Image $im->cropImage(420, 120, 0, 0); header("Content-Type: image/jpg"); // Display the image echo $im->getImageBlob(); ?> Output: Reference: http://php.net/manual/en/imagick.cropimage.php Comment More infoAdvertise with us Next Article PHP | Imagick cropImage() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP Image-Processing PHP-function PHP-Imagick +1 More Similar Reads PHP | Imagick chopImage() Function The Imagick::chopImage() function is an inbuilt function in PHP which is used to remove the region of an image and trim it. This function accepts the dimension of image and chops the area and the dimension from where the image is to be trim. Syntax: bool Imagick::chopImage( $width, $height, $x, $y ) 1 min read PHP | Gmagick cropimage() Function The Gmagick::cropimage() function is an inbuilt function in PHP which is used to extracts the region of the image. This function crop the part of image. Syntax: public Gmagick::cropimage( $width , $height , $x , $y ) Parameters: This function accept four parameters as mention above and describe belo 2 min read PHP | Gmagick chopimage() Function The Gmagick::chopimage() function is an inbuilt function in PHP which is used to remove the region of an image and trim it. This function accepts the dimension of image and chops the area and the dimension from where the image is to be trim.Syntax:Â Â Gmagick Gmagick::chopimage( $width, $height, $x, 2 min read PHP | Imagick flopImage() Function The Imagick::flopImage() function is an inbuilt function in PHP which is used to create a horizontal mirror image. Syntax: bool Imagick::flopImage( void ) Parameters: This function does not accept any parameter. Return Value: This function returns True on success. Below programs illustrate the Imagi 1 min read PHP | Imagick drawImage() Function The Imagick::drawImage() function is an inbuilt function in PHP which is used to render the ImagickDraw object on the Imagick object. It is used to draw the image on the Imagick instance. We set an image matrix, parameters and the borders of the drawn image with the help of ImagickDraw methods and t 2 min read Like