PHP | ImagickDraw setStrokeOpacity() Function Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The ImagickDraw::setStrokeOpacity() function is an inbuilt function in PHP which is used to specify the opacity of stroked object outlines. The value of opacity lies between 0 to 1. Syntax: bool ImagickDraw::setStrokeOpacity( $stroke_opacity ) Parameters: This function accepts a single parameter $stroke_opacity which is used to hold the value of stroke opacity as float type. Return Value: This function does not return any value. Below programs illustrates the ImagickDraw::setStrokeOpacity() function in PHP: Program 1: php <?php // require_once('path/vendor/autoload.php'); // Create an ImagickDraw object to draw into. $draw = new \ImagickDraw(); // Set the stroke color $draw->setStrokeColor('Green'); // Set the filled color $draw->setFillColor('Red'); // Set the stroke opacity $draw->setStrokeOpacity(0.5); // Set the stroke width $draw->setStrokeWidth(9); // Draw the rectangle $draw->rectangle(40, 30, 200, 260); // Create new imagick object $image = new \Imagick(); // Create new image of given size $image->newImage(240, 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: Program 2: php <?php // require_once('path/vendor/autoload.php'); // Create an ImagickDraw object to draw into. $draw = new \ImagickDraw(); // Set the Stroke Color $draw->setStrokeColor('Black'); // Set the Stroke Opacity $draw->setStrokeOpacity(0.6); // Set the Stroke Width $draw->setStrokeWidth(4); //Set the filled color $draw->setFillColor('lightgreen'); $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 $draw->polygon($points); // Create new Imagick object $image = new \Imagick(); // Set the 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: Reference: https://www.php.net/manual/en/imagickdraw.setstrokeopacity.php Comment More infoAdvertise with us Next Article PHP | ImagickDraw setFillOpacity() Function S sarthak_ishu11 Follow Improve Article Tags : Technical Scripter Web Technologies PHP Image-Processing PHP-function PHP-Imagick +2 More Similar Reads 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 setStrokeWidth() Function The ImagickDraw::setStrokeWidth() function is an inbuilt function in PHP which is used to set the width of the stroke used to draw object outlines. Syntax: bool ImagickDraw::setStrokeWidth( $stroke_width ) Parameters: This function accepts a single parameter $stroke_width which is used to hold the v 2 min read PHP | ImagickDraw setStrokeColor() Function 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 valu 2 min read PHP | ImagickDraw setFillOpacity() Function The ImagickDraw::setFillOpacity() function is an inbuilt function in PHP which is used to set the opacity to use when drawing using the fill color or fill texture.Syntax:Â bool ImagickDraw::setFillOpacity( $fillOpacity ) Parameters: This function accepts a single parameter $fillOpacity which is used 2 min read PHP | GmagickDraw setstrokewidth() Function The GmagickDraw::setstrokewidth() function is an inbuilt function in PHP which is used to set the width of the stroke used to draw object outlines. Syntax: public GmagickDraw::setstrokewidth( $stroke_width ) : GmagickDraw Parameters: This function accepts single parameter $stroke_width which is used 2 min read PHP | ImagickDraw setStrokePatternURL() Function The ImagickDraw::setStrokePatternURL() function is an inbuilt function in PHP which is used to set the pattern used for stroking object outlines. Syntax: bool ImagickDraw::setStrokePatternURL( string $stroke_url ) Parameters:This function accepts a single parameter $stroke_url which holds the URL of 2 min read Like