PHP | ImagickDraw popClipPath() Function
Last Updated :
30 Dec, 2019
The ImagickDraw::popClipPath() function is an inbuilt function in PHP which is used to terminate a clip-path definition. Clip paths are used to creates a clipping region that decides which part of an image should be shown. Parts that are inside the region are shown, while those outside are hidden.
Syntax:
bool ImagickDraw::popClipPath( void )
Parameters: This function doesn’t accepts any parameter.
Return Value: This function returns TRUE on success.
Below programs illustrate the ImagickDraw::popClipPath() function in PHP:
Program 1:
<?php
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'white' );
$draw = new ImagickDraw();
$draw ->setStrokeColor( 'blue' );
$draw ->setFillColor( 'cyan' );
$draw ->setStrokeWidth(2);
$draw ->pushClipPath( 'testClipPath' );
$draw ->rectangle(0, 0, 250, 250);
$draw ->popClipPath();
$draw ->setClipPath( 'testClipPath' );
$draw ->rectangle(50, 50, 350, 350);
$imagick ->drawImage( $draw );
$imagick ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Program 2:
<?php
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'white' );
$draw = new ImagickDraw();
$draw ->setFontSize(60);
$draw ->pushClipPath( 'testClipPath' );
$draw ->rectangle(0, 0, 250, 250);
$draw ->popClipPath();
$draw ->setClipPath( 'testClipPath' );
$draw ->annotation(0, 150, 'Hello World' );
$imagick ->drawImage( $draw );
$imagick ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagickdraw.popclippath.php
Share your thoughts in the comments
Please Login to comment...