(No version information available, might only be in Git)
Imagick::transparentPaintImage — Paints pixels transparent
Paints pixels matching the target color transparent. 锟剿凤拷锟斤拷锟斤拷Imagick锟斤拷锟斤拷ImageMagick 6.3.8锟斤拷锟较版本锟斤拷锟斤拷时锟斤拷锟矫★拷
target
The target color to paint
alpha
透锟斤拷锟斤拷锟斤拷1.0 锟斤拷锟斤拷全锟斤拷透锟斤拷锟斤拷0.0 锟斤拷锟斤拷全透锟斤拷锟斤拷
fuzz
The amount of fuzz. For example, set fuzz to 10 and the color red at intensities of 100 and 102 respectively are now interpreted as the same color.
invert
If TRUE
paints any pixel that does not match the target color.
锟缴癸拷时锟斤拷锟斤拷 TRUE
锟斤拷
Example #1 Imagick::transparentPaintImage()
<?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();
}
?>