The GmagickDraw::getstrokecolor() function is an inbuilt function in PHP which is used to get the color used for stroking object outlines.
Syntax:
ImagickPixel GmagickDraw::getstrokecolor( void )
Parameters: This function doesn’t accept any parameters.
Return Value: This function returns an GmagickPixel value containing the color.
Exceptions: This function throws GmagickDrawException on error.
Below given programs illustrate the GmagickDraw::getstrokecolor() function in PHP:
Program 1:
<?php // Create a new GmagickDraw object $draw = new GmagickDraw(); // Get the stroke color $strokeColor = $draw->getstrokecolor()->getcolor(); echo $strokeColor; ?> |
Output:
rgb(0, 0, 0)
Program 2:
<?php // Create a new GmagickDraw object $draw = new GmagickDraw(); // Set the stroke color $draw->setstrokecolor('#4a76bd'); // Get the stroke color $strokeColor = $draw->getstrokecolor()->getcolor(); echo $strokeColor; ?> |
Output:
rgb(19018, 30326, 48573)
Used Image:
Program 3:
<?php // Create a new Gmagick object $gmagick = new Gmagick('neveropen.png'); // Create a GmagickDraw object $draw = new GmagickDraw(); // Set the color $draw->setFillColor('#0E0E0E'); // Draw rectangle for background $draw->rectangle(-10, -10, 800, 400); // Set the fill color $draw->setFillColor('white'); // Set the color of stroke $draw->setStrokeColor('red'); // Set the width of stroke $draw->setstrokewidth(1); // Set the font size $draw->setFontSize(20); // Get the stroke color $strokecolor = $draw->getstrokecolor()->getcolor(); // Annotate a text $draw->annotate(50, 100, 'The stroke color here is ' . $strokecolor); // Use of drawimage functeannotate $gmagick->drawImage($draw); // Display the output image header("Content-Type: image/png"); echo $gmagick->getImageBlob(); ?> |
Output:
Reference: https://www.php.net/manual/en/gmagickdraw.getstrokecolor.php

