Saturday, May 23, 2026
HomeLanguagesPHP | ImagickDraw roundRectangle() Function

PHP | ImagickDraw roundRectangle() Function

The ImagickDraw::roundRectangle() function is an inbuilt function in Imagick library of PHP which is used to draw a rounded rectangle.

Syntax:

bool ImagickDraw::roundRectangle( $x1, $y1, $x2, $y2, $rx, $ry )

Parameters: This function accept six parameters as mentioned above and described below:

  • $x1: This parameter takes the value of x coordinate of the top left corner.
  • $y1: This parameter takes the value of y coordinate of the top left corner.
  • $x2: This parameter takes the value of x coordinate of the bottom right.
  • $y2: This parameter takes the value of y coordinate of the bottom right.
  • $rx: This parameter takes the value of x rounding.
  • $ry: This parameter takes the value of y rounding.

Return Value: This function returns TRUE on success.

Below program illustrates the ImagickDraw::roundRectangle() function in PHP:

Program:




<?php
// require_once('vendor/autoload.php');
  
// Create ImagickDraw object
$draw = new \ImagickDraw();
      
$draw->setStrokeColor('Green');
$draw->setFillColor('Red');
$draw->setStrokeWidth(7);
  
$draw->roundRectangle(40, 30, 250, 260, 40, 80);
  
// Create an image object which the draw 
// commands can be rendered into
$image = new \Imagick();
$image->newImage(300, 300, 'White');
$image->setImageFormat("png");
  
// Render the draw commands in the ImagickDraw object 
// into the image.
      
$image->drawImage($draw);
  
// Send the image to the browser
header("Content-Type: image/png");
echo $image->getImageBlob();
?>


Output:

Reference: http://php.net/manual/en/imagickdraw.roundrectangle.php

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32514 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6892 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12107 POSTS0 COMMENTS
Shaida Kate Naidoo
7016 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6975 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS