Search code examples
phpimageimage-processingimagemagickimagick

Imagick's resize() overlays a black grid on the result image


When using ImageMagick to resize (downsize in this case) an image, I get a black grid overlay on the image. The minimum reproducible code is:

$modifiedImage = new Imagick("an_image.png");
$modifiedImage->resizeImage(176,256,imagick::FILTER_LANCZOS,0,true);

When resizing this:

Original image

I get the following result:

Resized image, showing corruption

Any ideas as to what is going wrong here?


Solution

  • As Mark Setchell points out, it works in at least a following version of ImageMagick, released after the one I'm using (6.7.7-10 2014-03-06 Q16).

    I've found a temporary solution, without updating the package, by changing the filter to FILTER_BOX, instead of FILTER_LANCZOS.

    $modifiedImage->resizeImage($width,$height,imagick::FILTER_BOX,0,true);
    

    This correctly generates a downsized image, although the quality is lower (with higher performance/less time in the conversion, however).