5
votes

I need to write a script to blur an image. That wouldn't be a problem if I didn't need it to blur it really hard.

Now, GD's gaussian blur filter is really weak. And imageconvolution accepts only 3x3 matrixes for some reason so I can't generate gaussian matrix with larger radius for stronger blur? Even if I could, I'm not sure how fast it would be.

Running gaussian blur multiple times does the trick, but is really slow. To achieve effect I'm searching for, I need to run it 40-100 times over an image, and, ofcourse, it takes 10-20 seconds to finish.

Is there a way to achieve what I'm looking for in reasonable time using libraries that come bundled with PHP?

Here is the exact effect. Generation time: 10.972307920456 seconds. 80 passes.

Original:

enter image description here

Processed:

enter image description here

1
You could check how ImageMagick would perform. It has PHP native interface: imagemagick.org/Usage/blurddinchev
But I need it to come bundled with PHP, and it doesn't unfortunately. I would be really happy if somebody even knew about some extremely inaccurate but really fast algorithm which I could run over the image on per-pixel basis.user2742648
But GD (what you are currently using) is NOT bundled with PHP. It just has wrapper for PHP much like IM...ddinchev
You could check out stackblur filter and port it to PHP.bitWorking
A differt approach you could try is to resize the image to 10% of its original size and then either blow it up again or just have the browser render it in it's original size.Christiaan

1 Answers

0
votes

bool Imagick::blurImage ( float $radius , float $sigma [, int $channel ] )

a). $radius Blur radius

b). $sigma Standard deviation

c). $channel The Channeltype constant. When not supplied, all channels are blurred.