PHP/GD : Better Gaussian blur

SAFAD picture SAFAD · Aug 30, 2011 · Viewed 21.7k times · Source

I want to blur an image with GD library, unfortunately the GAUSSIAN_BLUR effect that GD gives isn't enough and i want something being more blurrish

<?php $im = imagecreatefrompng($_GET['image']);
if($im && imagefilter($im, IMG_FILTER_GAUSSIAN_BLUR))
{
  header('Content-Type: image/png');
    imagepng($im);
}
else
{
    echo 'fail';
}

imagedestroy($im);

I want something like this or at least near it. image from //tutorial9.s3.amazonaws.com/uploads/2008/06/lens-blur.jpg

Answer

Andrei Oniga picture Andrei Oniga · May 17, 2012

After coming across the same problem, I applied the same filter a few times, and each time to the resulting resource of the previous "imagefilter" call. I got the 'more blurry' effect you're looking for.

e.g.:

for ($x=1; $x<=15; $x++)
   imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR);