The Imagick::roundCorners() function is an inbuilt function in PHP which is used to round the image corners.
Syntax:
bool Imagick::roundCorners( float $x_rounding, float $y_rounding, float $stroke_width = 10, float $displace = 5, float $size_correction = -6 )
Parameters: This function accepts five parameters as mentioned above and described below:
- $x_rounding: It specifies the amount of x rounding.
- $y_rounding: It specifies the amount of y rounding.
- $stroke_width (Optional): It specifies the stroke width. Default value of this parameter is 10.
- $displace (Optional): It specifies the image displace. Default value of this parameter is 5.
- $size_correction (Optional): It specifies the size correction. Default value of this parameter is -6.
Return Value: This function returns TRUE on success.
Exceptions: This function throws ImagickException on error.
Below given programs illustrate the Imagick::roundCorners() function in PHP:
Program 1:
<?php // Create a new imagick object $imagick = new Imagick(
// Round the corners $imagick ->roundCorners(20, 20, 5, 5, -8);
// Display the image $imagick ->setImageFormat( 'jpg' );
header( "Content-Type: image/jpg" );
echo $imagick ->getImageBlob();
?> |
Output:
Program 2:
<?php // Create a new imagick object $imagick = new Imagick(
// Round the corners $imagick ->roundCorners(100, 100, 5);
// Display the image $imagick ->setImageFormat( 'jpg' );
header( "Content-Type: image/jpg" );
echo $imagick ->getImageBlob();
?> |
Output:
Reference: https://www.php.net/manual/en/imagick.roundcorners.php