Open In App

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:

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


Article Tags :