I had the code running to create a "cylinder" effect via ImageMagick v6.7.9 and PHP (Imagick extension v3.2.0), it's like described in the accepted answer of my previous question: https://stackoverflow.com/a/54807019/1800172 It's inspired by Fred's cylinderize script: http://www.fmwconcepts.com/imagemagick/cylinderize/
After creating the X/Y-displacements ($a3
/$a4
) it's combined like this:
// merge x-displacement and y-displacement into one displacement-map
$displaceMask = new Imagick();
$displaceMask->addImage($a3);
$displaceMask->addImage($a4);
$displaceMask->addImage($a4);
$displaceMask->mergeImageLayers(Imagick::LAYERMETHOD_FLATTEN);
$displaceMask = $displaceMask->combineImages(Imagick::CHANNEL_ALL);
$displaceMask->setImageArtifact('compose:args', '1600x83.669513037752');
$image->compositeImage($displaceMask, Imagick::COMPOSITE_DISPLACE, 0, 0);
$image->trimImage(0);
Now that I updated to ImageMagick v6.9.10 and Imagick v3.4.3 this does not produce the same image anymore. I already figured out that I had to change the way how to create the displacement map, to make it look the same as before:
// merge x-displacement and y-displacement into one displacement-map
$displaceMask = new Imagick();
$displaceMask->newImage($a3->getImageWidth(), $a3->getImageHeight(), new ImagickPixel('white'));
$displaceMask->setImageFormat('png');
$displaceMask->setImageColorspace(Imagick::COLORSPACE_RGB);
$displaceMask->compositeImage($a3, imagick::COMPOSITE_COPYRED, 0, 0);
$displaceMask->compositeImage($a4, imagick::COMPOSITE_COPYGREEN, 0, 0);
$displaceMask->compositeImage($a4, imagick::COMPOSITE_COPYBLUE, 0, 0);
But if I now apply the "composite" function with "displace" operator, the result looks not the same as with the old version:
$displaceMask->setImageArtifact('compose:args', '1600x83.669513037752');
$image->compositeImage($displaceMask, Imagick::COMPOSITE_DISPLACE, 0, 0);
$image->trimImage(0);
Expected resulting image (like before version update):
Resulting image (i.e. after version update):
My guess is that anything changed in Imagick and/or ImageMagick implementation, or in it's (default) configuration. Anyone who can point me to the solution?
Thanks in advance!
Edit: I updated the input image, it was not the one that I use as the input of the displacement.
Edit2: I tried to apply the displacement via ImageMagick directly instead of using Imagick, and there it seems to work (ignoring the fact that the resulting image is somehow pixelated, so it's not usable as a workaround so far):
convert input.png ( a3.png a4.png a4.png -combine ) -channel rgba -alpha on -virtual-pixel transparent -background none -define compose:args=1600x83.669513037752 -compose displace -composite result.png
--> Might be a problem/bug/change in Imagick itself?