php imagefilter 对图像使用过滤器
(PHP 5) imagefilter — 对图像使用过滤器 imagefilter() 把过滤器 filtertype 应用到图像上,在需要时使用 arg1,arg2 和 arg3。 filtertype 可以是下列中的一个: Note: 此函数仅在与 GD 库捆绑编译的 PHP 版本中可用。 成功时返回 TRUE, 或者在失败时返回 FALSE. Example #1 imagefilter() 灰度例子 Example #2 imagefilter() 亮度例子imagefilter
说明
bool imagefilter ( resource $src_im , int $filtertype [, int $arg1 [, int $arg2 [, int $arg3 ]]] )<?php
$im = imagecreatefrompng('dave.png');
if ($im && imagefilter($im, IMG_FILTER_GRAYSCALE)) {
echo 'Image converted to grayscale.';
imagepng($im, 'dave.png');
} else {
echo 'Conversion to grayscale failed.';
}
imagedestroy($im);
?><?php
$im = imagecreatefrompng('sean.png');
if ($im && imagefilter($im, IMG_FILTER_BRIGHTNESS, 20)) {
echo 'Image brightness changed.';
imagepng($im, 'sean.png');
} else {
echo 'Image brightness change failed.';
}
imagedestroy($im);
?>
Example #3 imagefilter() 上彩例子
<?php
$im = imagecreatefrompng('philip.png');
/* R, G, B, so 0, 255, 0 is green */
if ($im && imagefilter($im, IMG_FILTER_COLORIZE, 0, 255, 0)) {
echo 'Image successfully shaded green.';
imagepng($im, 'philip.png');
} else {
echo 'Green shading failed.';
}
imagedestroy($im);
?>