加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP / GD高斯模糊效应

发布时间:2020-12-13 16:36:56 所属栏目:PHP教程 来源:网络整理
导读:我需要使用 PHP和GD模糊图像的某个区域,目前我使用以下代码: for ($x = $_GET['x1']; $x $_GET['x2']; $x += $pixel){ for ($y = $_GET['y1']; $y $_GET['y2']; $y += $pixel) { ImageFilledRectangle($image,$x,$y,$x + $pixel - 1,$y + $pixel - 1,ImageC
我需要使用 PHP和GD模糊图像的某个区域,目前我使用以下代码:
for ($x = $_GET['x1']; $x < $_GET['x2']; $x += $pixel)
{
    for ($y = $_GET['y1']; $y < $_GET['y2']; $y += $pixel)
    {
        ImageFilledRectangle($image,$x,$y,$x + $pixel - 1,$y + $pixel - 1,ImageColorAt($image,$y));
    }
}

这基本上用一个像素像素的正方形代替了所选区域.我想完成某种模糊(高斯优选)效果,我知道我可以使用ImageFilter()函数:

ImageFilter($image,IMG_FILTER_GAUSSIAN_BLUR);

但是它会影响整个画布,我的问题是我只想模糊一个特定的区域.

您可以将图像的特定部分复制到新图像中,对新图像应用模糊并将结果复制回来.

像这样排序:

$image2 = imagecreate($width,$height);
imagecopy  ( $image2,$image,$width,$height);
imagefilter($image,IMG_FILTER_GAUSSIAN_BLUR);
imagecopy ($image,$image2,$height);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读