PHP uses Gaussian algorithm to implement image blur processing function example

黄舟
Release: 2023-03-06 06:10:02
Original
1909 people have browsed it

The example in this article describes the use of Gaussian algorithm in PHP to implement image blur processing. I share it with you for your reference. The details are as follows:

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[2]) { 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); ?>
Copy after login



This method came from Baidu. Someone interviewed me and asked me to do it. I got a lot of information from Baidu. accomplish.

The value of blurFactor represents the degree of blur

Effect display:

Original image:

PHP uses Gaussian algorithm to implement image blur processing function example

Blurry degree 2

PHP uses Gaussian algorithm to implement image blur processing function example

Blurry level 3

PHP uses Gaussian algorithm to implement image blur processing function example

Blurry level 4

PHP uses Gaussian algorithm to implement image blur processing function example

Blurry Level 5

PHP uses Gaussian algorithm to implement image blur processing function example

Blurry Level 6

PHP uses Gaussian algorithm to implement image blur processing function example

Blurry Level 7

PHP uses Gaussian algorithm to implement image blur processing function example

The above is the content of PHP using Gaussian algorithm to implement image blur processing function example. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!