2678777127 发表于 2018-2-11 12:02:07


            本文实例讲述了php使用高斯算法实现图片的模糊处理功能。分享给大家供大家参考,具体如下:
image_create_from_ext($srcImg);
    $srcImgObj=$this->blur($gdImageResource,$blurFactor);
    $temp = pathinfo($srcImg);
    $name = $temp['basename'];
    $path = $temp['dirname'];
    $exte = $temp['extension'];
    $savename = $savename ? $savename : $name;
    $savepath = $savepath ? $savepath : $path;
    $savefile = $savepath .'/'. $savename;
    $srcinfo = @getimagesize($srcImg);
    switch ($srcinfo) {
      case1: imagegif($srcImgObj, $savefile); break;
      case2: imagejpeg($srcImgObj, $savefile); break;
      case3: imagepng($srcImgObj, $savefile); break;
      default: return'保存失败'; //保存失败
    }
    return $savefile;
    imagedestroy($srcImgObj);
}
}
$image_blur = new image_blur();
//blurFactor的值代表模糊程度,savepath为空时候直接覆盖,savename为空直接用原名
$image_blur->gaussian_blur($srcImg="./5.jpg",$savepath=null,$savename=null,$blurFactor=5);
?>
页: [1]
查看完整版本: php使用高斯算法实现图片的模糊处理功能示例