Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am assuming that you are referring to the examples found here:</p> <p><a href="http://www.imagemagick.org/Usage/photos/" rel="nofollow">http://www.imagemagick.org/Usage/photos/</a></p> <p>With that said, I have been trying to accomplish the very same thing with PHP Imagick. I am using PHP Imagick 3.0.1 and ImageMagick 6.7.4-4 2012-01-09 Q16 in Linux.</p> <p>It appears that the blur composite mode is undocumented. I found it by looking through the ImageMagick source under <code>magick/composite.h</code> on line <code>88</code>.</p> <p>This code accomplishes what you are looking for:</p> <pre><code>$im = new Imagick(); $im-&gt;readImageBlob(file_get_contents($src)); $qr = $im-&gt;getQuantumRange(); $qr = $qr['quantumRangeLong']; $im-&gt;sigmoidalContrastImage(true, 10, $qr / 2, Imagick::CHANNEL_ALL); $blurmap = new Imagick(); $blurmap-&gt;setOption('compose:args', '5'); $blurmap-&gt;newPseudoImage($im-&gt;getImageWidth(), $im-&gt;getImageHeight(), 'gradient:black-white'); $blurmap-&gt;functionImage(Imagick::FUNCTION_POLYNOMIAL, array(4.5, -4.5, 1)); $blurmap-&gt;levelImage(0, 1, $qr / 2); $im-&gt;compositeImage($blurmap, 57, 0, 0); $blurmap-&gt;destroy(); </code></pre> <p>If you require more blur, simply change <code>compose:args</code> to <code>10</code> or something. One thing I figured out was that I had to set the option before I created/loaded anything into the wand itself.</p> <p>I could not get the <code>SparseColorImage()</code> function to behave as it does on the command line, although I am sure that someone else could contribute that part if they figure it out. The above is enough for my needs.</p> <p><strong>EDIT:</strong> Upon further inspection of the images generated I noticed that even the black parts of the blur map were being blurred. After some searching it appears that this stems from a bug introduced in ImageMagick. I switched to version 6.7.8-1 2012-07-05 Q16 and the blur map now appears to be working. If you notice unwanted blurring with the blur composite I suggest you upgrade your ImageMagick.</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. 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