Open In App

PHP | ImagickDraw getStrokeLineJoin() Function

Last Updated : 07 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The ImagickDraw::getStrokeLineJoin() function is an inbuilt function in PHP which is used to get the shape to be used at the corners of paths when they are stroked. This usually impacts the outer edges and turns of the stroke.

Syntax:

int ImagickDraw::getStrokeLineJoin( void )

Parameters: This function doesn’t accepts any parameters.

Return Value: This function returns an integer value corresponding to one of LINEJOIN constants.

List of LINEJOIN constants are given below:

  • imagick::LINEJOIN_UNDEFINED (0)
  • imagick::LINEJOIN_MITER (1)
  • imagick::LINEJOIN_ROUND (2)
  • imagick::LINEJOIN_BEVEL (3)

Exceptions: This function throws ImagickException on error.

Below programs illustrate the ImagickDraw::getStrokeLineJoin() function in PHP:

Program 1:




<?php
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
    
// Get the stroke line join
$lineJoin = $draw->getStrokeLineJoin();
echo $lineJoin;
?>


Output:

1 // Which corresponds to imagick::LINEJOIN_MITER

Program 2:




<?php
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
// Set the stroke line join
$draw->setStrokeLineJoin(3);
  
// Get the stroke line join
$lineJoin = $draw->getStrokeLineJoin();
echo $lineJoin;
?>


Output:

3 // Which corresponds to imagick::LINEJOIN_BEVEL

Program 3:




<?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 fill color
$draw->setFillColor('white');
    
// Set the color of stroke
$draw->setStrokeColor('blue');
  
// Set the stroke width
$draw->setStrokeWidth(4);
    
// Set the font size
$draw->setFontSize(25);
   
 // Set the stroke dash array
$draw->setStrokeDashArray([20]);
   
// Draw a rectangle
$draw->rectangle(100, 50, 225, 175);
    
// Annotate a text
$draw->annotation(10, 220, 'The strokeLineJoin here is '
        . $draw->getStrokeLineJoin());
   
// Set the stroke line join
$draw->setStrokeLineJoin(2);
    
// Draw a rectangle
$draw->rectangle(500, 50, 625, 175);
    
// Annotate a text
$draw->annotation(400, 220, 'The strokeLineJoin here is '
        . $draw->getStrokeLineJoin());
    
// Render the draw commands
$imagick->drawImage($draw);
    
// Show the output
$imagick->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>


Output:



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads