PHP | ImagickDraw setStrokeColor() Function Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The ImagickDraw::setStrokeColor() function is an inbuilt function in PHP which is used to set the color used for stroking object outlines. Syntax: bool ImagickDraw::setStrokeColor( $stroke_pixel ) Parameters: This function accepts a single parameter $stroke_pixel which is used to hold the color value. Return Value: This function does not return any value. Below programs illustrates the ImagickDraw::setStrokeColor() function in PHP: Program 1: php <?php // require_once('path/vendor/autoload.php'); // Create an ImagickDraw object $draw = new \ImagickDraw(); // Set stroke opacity $draw->setStrokeOpacity(1); // Set stroke color $draw->setStrokeColor('Black'); // Set stroke opacity $draw->setStrokeOpacity(0.8); // Set stroke width $draw->setStrokeWidth(10); // Set Stroke Line Join $draw->setStrokeLineJoin(Imagick::LINEJOIN_ROUND); // Set Fill Color $draw->setFillColor('lightgreen'); // Set Stroke Miter Limit $draw->setStrokeMiterLimit(40 * 12); $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 a polygon $draw->polygon($points); // Create a new Imagick object $image = new \Imagick(); // Set image dimensions $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 image echo $image->getImageBlob(); ?> Output: Program 2: php <?php // require_once('path/vendor/autoload.php'); // Create an ImagickDraw object $draw = new \ImagickDraw(); // Set the stroke color $draw->setStrokeColor('Green'); // Set Fill Color $draw->setFillColor('Red'); // Set the stroke width $draw->setStrokeWidth(7); // Draw the rectangle $draw->rectangle(40, 30, 200, 260); // Create new Imagick object $image = new \Imagick(); // Set the image dimension $image->newImage(300, 300, 'White'); // Set the image format $image->setImageFormat("png"); // Draw the image $image->drawImage($draw); header("Content-Type: image/png"); // Display the image echo $image->getImageBlob(); ?> Output: Reference: https://www.php.net/manual/en/imagickdraw.setstrokecolor.php Comment More infoAdvertise with us Next Article PHP | ImagickDraw setStrokeAlpha() 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 setstrokecolor() Function The GmagickDraw ::setstrokecolor() function is an inbuilt function in PHP which is used to set the color used for stroking object outlines. Syntax: public GmagickDraw::setstrokecolor( $color ) : GmagickDraw Parameters: This function accepts single parameter $color which is used to hold the color val 2 min read PHP | GmagickDraw setstrokecolor() Function The GmagickDraw ::setstrokecolor() function is an inbuilt function in PHP which is used to set the color used for stroking object outlines. Syntax: public GmagickDraw::setstrokecolor( $color ) : GmagickDraw Parameters: This function accepts single parameter $color which is used to hold the color val 2 min read PHP | ImagickDraw setStrokeAlpha() Function The ImagickDraw::setStrokeAlpha() function is an inbuilt function in PHP which is used to specify the opacity of stroked object outlines. Syntax: bool ImagickDraw::setStrokeAlpha( $opacity ) Parameters: This function accepts a single parameter opacity which is used to specify the transparency of str 2 min read PHP | ImagickDraw setStrokeAlpha() Function The ImagickDraw::setStrokeAlpha() function is an inbuilt function in PHP which is used to specify the opacity of stroked object outlines. Syntax: bool ImagickDraw::setStrokeAlpha( $opacity ) Parameters: This function accepts a single parameter opacity which is used to specify the transparency of str 2 min read PHP | ImagickDraw setStrokeLineJoin() Function The ImagickDraw::setStrokeLineJoin() function is an inbuilt function in PHP that is used to specify the shape to be used at the corners of paths when they are stroked. Syntax:Â bool ImagickDraw::setStrokeLineJoin( $linejoin ) Parameters: This function accepts a single parameter $linejoin which is us 2 min read PHP | ImagickDraw setStrokeLineJoin() Function The ImagickDraw::setStrokeLineJoin() function is an inbuilt function in PHP that is used to specify the shape to be used at the corners of paths when they are stroked. Syntax:Â bool ImagickDraw::setStrokeLineJoin( $linejoin ) Parameters: This function accepts a single parameter $linejoin which is us 2 min read Like