Imagick::transparentPaintImage
(PECL imagick 2 >= 2.3.0, PECL imagick 3)
Imagick::transparentPaintImage — Paints pixels transparent
说明
public Imagick::transparentPaintImage(
mixed
float
float
bool
): bool
mixed
$target
,float
$alpha
,float
$fuzz
,bool
$invert
): bool
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
。
示例
示例 #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();
}
?>
+添加备注
用户贡献的备注 1 note
josecarlosphp ¶
1 year ago
The $color parameter can be a string like this:
"rgb(255, 255, 255)"
As you can guess, that example represents white color.
"rgb" indicates red-green-blue, and numeric values are amounts for each, from 0 to 255.
Black color it will be "rgb(0, 0, 0)".
Full red color it will be "rgb(255, 0, 0)".
备份地址:http://www.lvesu.com/blog/php/imagick.transparentpaintimage.php