The ImagickDraw::line() function is an inbuilt function in Imagick library of PHP which is used to draw a line. This function draw the line using the current stroke color, stroke opacity, and stroke width.
Syntax:
bool ImagickDraw::line( $sx, $sy, $ex, $ey )
Parameters: This function accepts four parameters as mentioned above and described below:
- $sx: This parameter takes the value of starting x coordinate.
- $sy: This parameter takes the value of starting y coordinate.
- $ex: This parameter takes the value of ending x coordinate.
- $ey: This parameter takes the value of ending y coordinate.
Return Value: This function returns TRUE on success.
Below programe illsutarte the ImagickDraw::line() function in PHP:
Program:
<?php // Create an Imagick object $draw = new \ImagickDraw(); // Function to fill color $draw->setFillColor('red'); // Function to draw line $draw->line(10, 30, 180, 200); // Create Imagick object $imagick = new \Imagick(); // Create new image of given size $imagick->newImage(300, 300, 'white'); // Set the image format $imagick->setImageFormat("png"); // Function to draw the image $imagick->drawImage($draw); header("Content-Type: image/png"); // Display the output image echo $imagick->getImageBlob(); ?> |
Output:

Reference: http://php.net/manual/en/imagickdraw.line.php
Recommended Posts:
- PHP | ImagickDraw pop() Function
- PHP | ImagickDraw arc() Function
- PHP | ImagickDraw getStrokeLineCap() Function
- PHP | ImagickDraw getStrokeLineJoin() Function
- PHP | ImagickDraw getTextDecoration() Function
- PHP | ImagickDraw getStrokeMiterLimit() Function
- PHP | ImagickDraw getTextAlignment() Function
- PHP | ImagickDraw setStrokeDashOffset() Function
- PHP | ImagickDraw skewX() Function
- PHP | ImagickDraw getTextAntialias() Function
- PHP | ImagickDraw setStrokeLineCap() Function
- PHP | ImagickDraw getTextInterlineSpacing() Function
- PHP | ImagickDraw getStrokeColor() Function
- PHP | ImagickDraw getGravity() Function
- PHP | ImagickDraw getFillRule() Function
- PHP | ImagickDraw pathCurveToSmoothAbsolute() Function
- PHP | ImagickDraw setFillRule() Function
- PHP | ImagickDraw getFontStyle() Function
- PHP | ImagickDraw setFillOpacity() Function
- PHP | ImagickDraw setStrokeMiterLimit() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

