Change language

PHP Imagick setImageClipMask () Function

|
Syntax:
bool Imagick::setImageClipMask (Imagick $clip_mask)
Parameters:this function takes $clip_maskas a parameter that contains the mask of the image clip.Return value:this function returns TRUE on success.Exceptions:this function throws an ImagickException on error.The programs below illustrate the Imagick::setImageClipMask() functionin PHP:Program 1:  
// Create two new imagick objects $imagick = new Imagick ( https://media.engineerforengineer.org/wp-content/uploads/engineerforengineer-13.png ); $clipMask = new Imagick(); $clipMask -> setGravity (4);  
// Add text to the object $clipMask -> newPseudoImage ( $imagick -> getImageWidth(), $imagick -> getImageHeight(), "caption: ClipMaskText" );  
// Set clip mask $imagick -> setImageClipMask ( $clipMask ); $imagick -> negateImage (false);  
// Show output $imagick -> setformat ( ’png’ ); header ( "Content-Type: image / png" ); echo $imagick -> getImageBlob(); ?>
Output:Program 2:  
// Create two new imagick objects $imagick = new Imagick ( https://media.engineerforengineer.org/wp-content/uploads/engineerforengineer-13.png ); $clipMask = new Imagick();  
// Create rectangular mask $clipMask -> newPseudoImage ( $imagick -> getImageWidth(), $imagick -> getImageHeight(), "canvas: Transparent" ); $drawMask = new ImagickDraw(); $drawMask -> setFillColor ( ’white’ ); $drawMask -> rectangle-method/">rectangle (170, 0, 470, 300); $clipMask -> drawImage ( $drawMask );  
// Set clip mask $imagick -> setImageClipMask ( $clipMask ); $imagick -> negateImage (false);  
// Show output $imagick -> setformat ( ’png’ ); header ( "Content-Type: image / png" ); echo $imagick -> getImageBlob(); ?>
Output: Link: https://www.php.net/manual/en/imagick.setimageclipmask.php
SO 1 data error