How to achieve a blur effect in PHP?

前端 未结 3 369
误落风尘
误落风尘 2020-12-15 14:31

I\'ve been looking for PHP code to apply a Gaussian blur to images.

What I\'ve done was like this:



        
相关标签:
3条回答
  • 2020-12-15 15:11

    It is possible also without ImageMagic lib;

    header('Content-Type: image/png');
    
    $blurs = 10;
    $image = imagecreatefrompng('blur.png');
    for ($i = 0; $i < $blurs; $i++) {
        imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR);
    }
    imagepng($image, 'blur10.png');
    imagedestroy($image);
    

    After 10 blur applied;

    enter image description here

    0 讨论(0)
  • 2020-12-15 15:19

    Image optimization is very heavy process so personally if i have these kind of task in PHP then i use this PHP Image Library Called PhpThumb it can create blur images without any code you just need to call it's script via url and provide parameters according to its docs check it's demo.

    0 讨论(0)
  • 2020-12-15 15:23

    You can use ImageMagic

    Original Image

    enter image description here

    Run via exec

    convert a.png -blur 0x3 a_blur.png
    

    Output

    OR Run

    convert a.png -blur 0x8 a_blur.png
    

    enter image description here

    0 讨论(0)
提交回复
热议问题