The ImagickDraw::getStrokeMiterLimit() function is an inbuilt function in PHP which is used to get the miter limit. When two line segments meet at a sharp angle, miter joins extend far beyond the thickness of the line stroking the path.
Syntax:
int ImagickDraw::getStrokeMiterLimit( void )
Parameters: This function doesn’t accept any parameter.
Return Value: This function returns an integer value containing the miter limit.
Exceptions: This function throws ImagickException on error.
Below given programs illustrate the ImagickDraw::getStrokeMiterLimit() function in PHP:
Program 1:
<?php // Create a new ImagickDraw object $draw = new ImagickDraw(); // Get the stroke miter limit $miterLimit = $draw ->getStrokeMiterLimit(); echo $miterLimit ; ?> |
Output:
10
Program 2:
<?php // Create a new ImagickDraw object $draw = new ImagickDraw(); // Create a new imagick object $imagick = new Imagick(); // Create a image on imagick object $imagick ->newImage(800, 250, 'white' ); // Create a new ImagickDraw object $draw = new ImagickDraw(); // Set the stroke color $draw ->setStrokeColor( 'green' ); // Set the stroke opacity $draw ->setStrokeOpacity(0.6); // Set the fill color $draw ->setFillColor( 'white' ); // Set the stroke width $draw ->setStrokeWidth(10); // Set the stroke Line Join $draw ->setStrokeLineJoin(Imagick::LINEJOIN_MITER); // Set the stroke miter limit $draw ->setStrokeMiterLimit(0); // Create a polygon $draw ->polygon([ [ 'x' => 100, 'y' => 60], [ 'x' => 60, 'y' => 80], [ 'x' => 400, 'y' => 100] ]); // Set the font size $draw ->setFontSize(20); // Decrease the stroke width so that text can be printed $draw ->setStrokeWidth(1); // Print the text $draw ->annotation(450, 100, 'The strokeMiterLimit here is ' . $draw ->getStrokeMiterLimit()); // Set the stroke width back to 10 $draw ->setStrokeWidth(10); // Set the stroke miter limit $draw ->setStrokeMiterLimit(40); // Create a polygon $draw ->polygon([ [ 'x' => 100, 'y' => 160], [ 'x' => 60, 'y' => 180], [ 'x' => 400, 'y' => 180] ]); // Decrease the stroke width so that text can be printed $draw ->setStrokeWidth(1); // Print the text $draw ->annotation(450, 180, 'The strokeMiterLimit here is ' . $draw ->getStrokeMiterLimit()); // Render the draw commands $imagick ->drawImage( $draw ); // Show the output $imagick ->setImageFormat( 'png' ); header( "Content-Type: image/png" ); echo $imagick ->getImageBlob(); ?> |
Output:
Reference: https://www.php.net/manual/en/imagickdraw.getstrokemiterlimit.php