PHP | Imagick setImageClipMask() Function
Last Updated :
20 Nov, 2019
The Imagick::setImageClipMask() function is an inbuilt function in PHP which is used to set the image clip mask.
Syntax:
bool Imagick::setImageClipMask( Imagick $clip_mask )
Parameters: This function accepts $clip_mask as parameter which holds the image clip mask.
Return Value: This function returns TRUE on success.
Exceptions: This function throws ImagickException on error.
Below given programs illustrate the Imagick::setImageClipMask() function in PHP:
Program 1:
<?php
$imagick = new Imagick(
$clipMask = new Imagick();
$clipMask ->setGravity(4);
$clipMask ->newPseudoImage( $imagick ->getImageWidth(),
$imagick ->getImageHeight(), "caption:ClipMaskText" );
$imagick ->setImageClipMask( $clipMask );
$imagick ->negateImage(false);
$imagick ->setformat( 'png' );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Program 2:
<?php
$imagick = new Imagick(
$clipMask = new Imagick();
$clipMask ->newPseudoImage( $imagick ->getImageWidth(),
$imagick ->getImageHeight(), "canvas:Transparent" );
$drawMask = new ImagickDraw();
$drawMask ->setFillColor( 'white' );
$drawMask ->rectangle(170, 0, 470, 300);
$clipMask ->drawImage( $drawMask );
$imagick ->setImageClipMask( $clipMask );
$imagick ->negateImage(false);
$imagick ->setformat( 'png' );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagick.setimageclipmask.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...