PHP | Imagick roundCorners() Function

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?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();
?>

chevron_right


Output:

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?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();
?>

chevron_right


Output:

Reference: https://www.php.net/manual/en/imagick.roundcorners.php




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.