Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The simple solution is to scale the image down before you apply the blur filter. Here are some examples:</p> <p><strong>Original image:</strong></p> <p><img src="https://i.stack.imgur.com/DkIzu.jpg" alt="Photo of a cat (public domain: Longhair_Tabby_JaJa.jpg from Wikimedia Commons)"></p> <p><strong>20× Gaussian Blur (2.160 seconds):</strong></p> <pre><code>{ $start = microtime(true); for ($x=0; $x&lt;20; $x++) { imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR); } $end = microtime(true); $howlong = $end - $start; } </code></pre> <p><img src="https://i.stack.imgur.com/8szk3.jpg" alt="Result of applying Gaussian blur filter 20 times"></p> <p><strong>Combination of scaling and Gaussian blur (0.237 seconds):</strong></p> <pre><code>{ $start = microtime(true); /* Scale by 25% and apply Gaussian blur */ $s_img1 = imagecreatetruecolor(160,120); imagecopyresampled($s_img1, $image, 0, 0, 0, 0, 160, 120, 640, 480); imagefilter($s_img1, IMG_FILTER_GAUSSIAN_BLUR); /* Scale result by 200% and blur again */ $s_img2 = imagecreatetruecolor(320,240); imagecopyresampled($s_img2, $s_img1, 0, 0, 0, 0, 320, 240, 160, 120); imagedestroy($s_img1); imagefilter($s_img2, IMG_FILTER_GAUSSIAN_BLUR); /* Scale result back to original size and blur one more time */ imagecopyresampled($image, $s_img2, 0, 0, 0, 0, 640, 480, 320, 240); imagedestroy($s_img2); imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR); $end = microtime(true); $howlong = $end - $start; } </code></pre> <p><img src="https://i.stack.imgur.com/96ppi.jpg" alt="Result of applying a combination of image scaling and Gaussian blur"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload