PHP | imagecropauto() Function Last Updated : 29 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The imagecropauto() function is an inbuilt function in PHP which is used to crop an image automatically using one of the available modes. Syntax: resource imagecropauto( resource $image, int $mode, float $threshold, int $color ) Parameters: This function accepts four parameters as mentioned above and described below: $image: It specifies the image resource to be cropped. $mode (Optional): It specifies an integer corresponding to a crop mode. List of CROP modes are given below: IMG_CROP_DEFAULT (0) IMG_CROP_TRANSPARENT (1) IMG_CROP_BLACK (2) IMG_CROP_WHITE (3) IMG_CROP_SIDES (4) IMG_CROP_THRESHOLD (5) $threshold (Optional): It specifies the tolerance in percent to be used while comparing the image color and the color to crop. $color (Optional): It specifies either an RGB color value or a palette index. Return Value: This function returns TRUE on success. Exceptions: This function throws Exception on error. Below given programs illustrate the imagecropauto() function in PHP: Program 1: php <?php // Load the png image $im = imagecreatefrompng( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Crop the extra white area $cropped = imagecropauto($im, IMG_CROP_WHITE); // Convert it to a png file header('Content-type: image/png'); imagepng($cropped); ?> Output: Program 2: php <?php // Load the png image $im = imagecreatefrompng( 'https://media.geeksforgeeks.org/wp-content/uploads/20200123135210/geeksforgeeksinverted.png'); // Crop the image $cropped = imagecropauto($im, IMG_CROP_BLACK); // Convert it to a png file header('Content-type: image/png'); imagepng($cropped); ?> Output: Reference: https://www.php.net/manual/en/function.imagecropauto.php Comment More infoAdvertise with us Next Article PHP | imagecropauto() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads PHP | imagecrop() Function 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 fun 1 min read PHP | imagecopy() Function The imagecopy() function is an inbuilt function in PHP which is used to copy the image or part of image. This function returns true on success or false on failure. Syntax: bool imagecopy ( $dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h ) Parameters: This function accepts eigh 2 min read PHP | imagecreate() Function The imagecreate() function is an inbuilt function in PHP which is used to create a new image. This function returns the blank image of given size. In general imagecreatetruecolor() function is used instead of imagecreate() function because imagecreatetruecolor() function creates high quality images. 2 min read PHP | imagecharup() Function The imagecharup() function is an inbuilt function in PHP which is used to draw a character vertically. This function draws the first character of a string in the image identified by the image with its x and y-axis. The coordinate of the top-left corner is (0, 0). Syntax: bool imagecharup( $image, $f 2 min read PHP | imagechar() Function The imagechar() function is an inbuilt function in PHP which is used to draw a character horizontally. This function draws the first character of string in the image identified by image with its x and y-axis. The coordinate of the top-left corner is (0, 0). Syntax: bool imagechar( $image, $font, $x, 2 min read Like