PHP | ImagickDraw polygon() Function Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The ImagickDraw::polygon() function is an inbuilt function in Imagick library in PHP which is used to draw a polygon using the specified array of coordinates. Syntax: bool ImagickDraw::polygon( $coordinates ) Parameters: This function accepts single parameter $coordinates of array type. It is used to hold the set of points.Return Value: This function returns TRUE on success. Below program illustrate the ImagickDraw::polygon() function in PHP: Program: PHP <?php // require_once('vendor/autoload.php'); // Create an ImagickDraw object $draw = new \ImagickDraw(); // Set the opacity of image $draw->setStrokeOpacity(1); // Set the color of image $draw->setStrokeColor('Green'); // Set the stroke width $draw->setStrokeWidth(4); // Set the fill color $draw->setFillColor('Red'); // Array contains points $points = [ ['x' => 50 * 6, 'y' => 10 * 5], ['x' => 20 * 7, 'y' => 30 * 5], ['x' => 60 * 8, 'y' => 50 * 5], ['x' => 70 * 3, 'y' => 15 * 5], ]; // Draw the polygon with given points $draw->polygon($points); // Create an Imagick object $image = new \Imagick(); // Create an image of given size $image->newImage(500, 300, 'white'); // Set the image format $image->setImageFormat("png"); // Draw the image $image->drawImage($draw); header("Content-Type: image/png"); // Display the output image echo $image->getImageBlob(); ?> Output: Reference: https://www.php.net/manual/en/imagickdraw.polygon.php Comment More infoAdvertise with us Next Article PHP | ImagickDraw pop() Function S sarthak_ishu11 Follow Improve Article Tags : Misc Technical Scripter Web Technologies PHP Image-Processing PHP-function PHP-Imagick +3 More Practice Tags : Misc Similar Reads PHP | GmagickDraw polygon() Function The GmagickDraw::polygon() function is an inbuilt function in PHP which is used to draw a polygon using the current stroke, stroke width, and fill color or texture, using the specified array of coordinates. Syntax: GmagickDraw GmagickDraw::polygon( array $coordinates ) Parameters: This function acce 2 min read PHP | ImagickDraw polyline() Function The ImagickDraw::polyline() function is an inbuilt function in Imagick library of PHP which is used to draw a polyline using the current stroke, stroke width, and fill color or texture, using the specified array of coordinates. Syntax: bool ImagickDraw::polyline( $coordinates ) Parameters: This func 2 min read PHP | ImagickDraw point() Function The ImagickDraw::point() function is an inbuilt function in Imagick library of PHP which is used to draw a point. This function uses current stroke color and stroke thickness at the specified coordinates. Syntax: bool ImagickDraw::point( $x, $y ) Parameters: This function accepts two parameters as m 1 min read PHP | ImagickDraw pop() Function The ImagickDraw::pop() function is an inbuilt function in PHP which is used to destroy the current ImagickDraw in the stack and returns the previously pushed ImagickDraw. For every pop() function there must have already been an equivalent push() function. Syntax: bool ImagickDraw::pop( void ) Parame 2 min read PHP | GmagickDraw polyline() Function The GmagickDraw::polyline() function is an inbuilt function in PHP which is used to draw a polyline using the current stroke, stroke width, and fill color or texture, using the specified array of coordinates. Syntax: GmagickDraw GmagickDraw::polyline( array $coordinates_array ) Parameters: This func 2 min read PHP | GmagickDraw point() Function The GmagickDraw::point() function is an inbuilt function in PHP which is used to draw a point. This function uses current stroke color and stroke thickness at the specified coordinates. Syntax: public GmagickDraw::point( $x, $y ) Â Parameters:This function accepts two parameters as mentioned above a 2 min read Like