PHP | imagecropauto() Function
Last Updated :
29 Jan, 2020
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:
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
$im = imagecreatefrompng(
$cropped = imagecropauto( $im , IMG_CROP_WHITE);
header( 'Content-type: image/png' );
imagepng( $cropped );
?>
|
Output:
Program 2:
<?php
$im = imagecreatefrompng(
$cropped = imagecropauto( $im , IMG_CROP_BLACK);
header( 'Content-type: image/png' );
imagepng( $cropped );
?>
|
Output:
Reference: https://www.php.net/manual/en/function.imagecropauto.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...