HomeImagickImagickDrawImagickPixelImagick Pixel IteratorImagick KernelTutorial Source codeReport an issue

Merge image layers

← medianFilterImage   modulateImage →
Merges image layers into one. This method is useful when working with image formats that use multiple layers such as PSD. The merging is controlled using the layer_method which defines how the layers are merged. This method is available if Imagick has been compiled against ImageMagick version 6.3.7 or newer.
function mergeImageLayers($layerMethod)
    //$imagick = new \Imagick(realpath("images/LayerTest.psd"));
    //$imagick = new \Imagick(realpath("../public/images/Biter_500.jpg"));
    $imagick = new \Imagick(realpath("../public/images/redDiscAlpha.png"));
//    $imagick = new \Imagick();
    $blueDisc = new \Imagick(realpath("../public/images/blueDiscAlpha.png"));

//    $imagick->addImage($whiteDisc);
    $greenDisc = new \Imagick(realpath("../public/images/greenDiscAlpha.png"));

    $result = $imagick->mergeImageLayers($layerMethod);
    header("Content-Type: image/png");

    echo $result->getImageBlob();