imagefilter
对图像应用滤镜
PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8
imagefilter 函数用于对图像应用滤镜。该函数可以对 GD 库创建的图像进行滤镜效果处理,例如调节图像的对比度、亮度、饱和度,或者应用各种预设的视觉效果。
bool imagefilter ( resource $image , int $filtertype [, int $arg1 = 0 [, int $arg2 = 0 [, int $arg3 = 0 ]]] )
如果成功,返回 true;如果失败,返回 false。
以下是如何使用 imagefilter 函数将图像的亮度调整为 50 的示例:
<?php // 创建图像资源 $image = imagecreatefromjpeg('example.jpg'); <p>// 调整图像亮度<br> imagefilter($image, IMG_FILTER_BRIGHTNESS, 50);</p> <p>// 输出图像<br> header('Content-Type: image/jpeg');<br> imagejpeg($image);</p> <p>// 释放内存<br> imagedestroy($image);<br> ?><br>