PHP | imagecrop() Function Last Updated : 11 Jul, 2025 Comments Improve Suggest changes 1 Likes Like Report The imagecrop() function is an inbuilt function in PHP which is used to crop an image to the given rectangle. This function crops an image to the given rectangular area and returns the resulting image. The given image is not modified. Syntax: resource imagecrop ( $image, $rect ) Parameters: This function accepts two parameters as mentioned above and described below: $image: It is returned by one of the image creation functions, such as imagecreatetruecolor(). It is used to create size of image. $rect: The cropping rectangle as array with keys x, y, width and height. Return Value: This function return cropped image resource on success or False on failure. Below programs illustrate the imagecrop() function in PHP: Program: php <?php // Create an image from given image $im = imagecreatefrompng( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-9.png'); // find the size of image $size = min(imagesx($im), imagesy($im)); // Set the crop image size $im2 = imagecrop($im, ['x' => 0, 'y' => 0, 'width' => 250, 'height' => 150]); if ($im2 !== FALSE) { header("Content-type: image/png"); imagepng($im2); imagedestroy($im2); } imagedestroy($im); ?> output: Related Articles: PHP | gd_info() Function PHP | imagearc() Function Reference: https://www.php.net/manual/en/function.imagecrop.php Create Quiz Comment V vijay_raj Follow 1 Improve V vijay_raj Follow 1 Improve Article Tags : Misc Web Technologies PHP Image-Processing PHP-function +1 More Explore PHP Tutorial 8 min read BasicsPHP Syntax 4 min read PHP Variables 5 min read PHP | Functions 8 min read PHP Loops 4 min read ArrayPHP Arrays 5 min read PHP Associative Arrays 4 min read Multidimensional arrays in PHP 5 min read Sorting Arrays in PHP 4 min read OOPs & InterfacesPHP Classes 2 min read PHP | Constructors and Destructors 5 min read PHP Access Modifiers 4 min read Multiple Inheritance in PHP 4 min read MySQL DatabasePHP | MySQL Database Introduction 4 min read PHP Database connection 2 min read PHP | MySQL ( Creating Database ) 3 min read PHP | MySQL ( Creating Table ) 3 min read PHP AdvancePHP Superglobals 6 min read PHP | Regular Expressions 12 min read PHP Form Handling 4 min read PHP File Handling 4 min read PHP | Uploading File 3 min read PHP Cookies 9 min read PHP | Sessions 7 min read Like