PHP | ImagickDraw polyline() Function Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report 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 function accepts a single parameter $coordinates which is used to hold the coordinates of the point as an array. Return Value: This function returns True on success. Below programs illustrates the ImagickDraw::polyline() function in PHP: Program 1: php <?php // Create an ImagickDraw Object $draw = new ImagickDraw(); // Set Stroke Opacity $draw->setStrokeOpacity(1); // Set Stroke Color $draw->setStrokeColor('green'); // Set Fill Color $draw->setFillColor('red'); // Set Stroke Width $draw->setStrokeWidth(5); // Define the points at which lines to be draw $points = [ ['x' => 40 * 5, 'y' => 10 * 5], ['x' => 20 * 5, 'y' => 20 * 5], ['x' => 70 * 5, 'y' => 50 * 5], ['x' => 60 * 5, 'y' => 15 * 5] ]; // Call Polyline Function $draw->polyline($points); // Create an Imagick Object $image = new Imagick(); // Create new Image $image->newImage(500, 300, 'white'); // Set Image Format $image->setImageFormat("png"); // Draw Image $image->drawImage($draw); header("Content-Type: image/png"); // Display the output image echo $image->getImageBlob(); ?> Output: Program 2: php <?php // Create an ImagickDraw Object $draw = new ImagickDraw(); // Set Stroke Opacity $draw->setStrokeOpacity(1); // Set Stroke Color $draw->setStrokeColor('Black'); // Set Fill Color $draw->setFillColor('Green'); // Set Stroke Width $draw->setStrokeWidth(3); // Define the points at which lines to be draw $points = [ ['x' => 40 * 5, 'y' => 10 * 5], ['x' => 20 * 5, 'y' => 20 * 5], ['x' => 70 * 5, 'y' => 50 * 5], ['x' => 40 * 5, 'y' => 10 * 5] ]; // Set the Font Size $draw->setFontSize(50); // Set the font family $draw->setFontFamily('Ubuntu-Mono'); // Set the text to be added $draw->annotation(30, 40, "GeeksForGeeks"); // Call Polyline Function $draw->polyline($points); // Create an Imagick Object $image = new Imagick(); // Create new Image $image->newImage(500, 300, 'white'); // Set Image Format $image->setImageFormat("png"); // Draw 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.polyline.php Comment More infoAdvertise with us Next Article PHP | ImagickDraw polygon() Function S sarthak_ishu11 Follow Improve Article Tags : Technical Scripter Web Technologies PHP Image-Processing PHP-function PHP-Imagick +2 More Similar Reads 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 | ImagickDraw polygon() Function 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 2 min read PHP | ImagickDraw polygon() Function 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 2 min read PHP | ImagickDraw polygon() Function 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 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 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 Like