Imagick::setImageClipMask
(PECL imagick 2 >= 2.3.0, PECL imagick 3)
Sets image clip mask
Function-3-4-4
Description
Imagick::setImageClipMask(Imagick $clip_mask): bool
Sets image clip mask from another Imagick object. 0x636
Parameters
clip_maskThe Imagick object containing the clip mask
Return Values
Success
Errors/Exceptions
Throws
Examples
php
<?php
function setImageClipMask($imagePath) {
$imagick = new \Imagick();
$imagick->readImage(realpath($imagePath));
$width = $imagick->getImageWidth();
$height = $imagick->getImageHeight();
$clipMask = new \Imagick();
$clipMask->newPseudoImage(
$width,
$height,
"canvas:transparent"
);
$draw = new \ImagickDraw();
$draw->setFillColor('white');
$draw->circle(
$width / 2,
$height / 2,
($width / 2) + ($width / 4),
$height / 2
);
$clipMask->drawImage($draw);
$imagick->setImageClipMask($clipMask);
$imagick->negateImage(false);
$imagick->setFormat("png");
header("Content-Type: image/png");
echo $imagick->getImagesBlob();
}
?>