Friday, October 24, 2025
HomeLanguagesPHP | Imagick roundCorners() Function

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:




<?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

RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS