PHP | ImagickDraw setClipPath() Function
Last Updated :
23 Dec, 2019
The ImagickDraw::setClipPath() function is an inbuilt function in PHP which is used to associate a named clipping path with the image. Only the areas drawn on by the clipping path will be modified as long as it remains in effect.
Syntax:
bool ImagickDraw::setClipPath( string $clip_mask )
Parameters: This function accepts a single parameter $clip_mask which holds the clip mask.
Return Value: This function returns TRUE on success.
Exceptions: This function throws ImagickException on error.
Below given programs illustrate the ImagickDraw::setClipPath() function in PHP:
Program 1:
<?php
$draw = new ImagickDraw();
$draw ->setClipPath( 'nameOfClipPath' );
echo $draw ->getClipPath();
?>
|
Output:
nameOfClipPath
Program 2:
<?php
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'green' );
$draw = new ImagickDraw();
$draw ->pushClipPath( 'myClipPath' );
$draw ->rectangle(100, 40, 200, 200);
$draw ->popClipPath();
$draw ->setClipPath( 'myClipPath' );
$draw ->rectangle(10, 100, 400, 400);
$draw ->line(100, 100, 400, 400);
$imagick ->drawImage( $draw );
$imagick ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagickdraw.setclippath.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...