Imagick::transparentPaintImage
PHP function
Edit on GitHub ✎
(PECL imagick 2 >= 2.3.0, PECL imagick 3)
Paints pixels transparent
Description
Imagick::transparentPaintImage(mixed $target, float $alpha, float $fuzz, bool $invert): bool
Paints pixels matching the target color transparent. 0x638
Parameters
targetThe target color to paint
alphaAlpha
fuzzFuzz
invertIf true paints any pixel that does not match the target color.
Return Values
Success
Examples
Imagick::transparentPaintImage()
php
<?php
function transparentPaintImage($color, $alpha, $fuzz) {
$imagick = new \Imagick(realpath("images/BlueScreen.jpg"));
//Need to be in a format that supports transparency
$imagick->setimageformat('png');
$imagick->transparentPaintImage(
$color, $alpha, $fuzz * \Imagick::getQuantum(), false
);
//Not required, but helps tidy up left over pixels
$imagick->despeckleimage();
header("Content-Type: image/png");
echo $imagick->getImageBlob();
}
?>