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. Available since 6.3.7
Layer method type
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. Available since 6.3.7
Parameters
layer_methodintOne of the Imagick::LAYERMETHOD_* constants
function mergeImageLayers($layerMethodType)
{
    //$imagick = new \Imagick(realpath("images/LayerTest.psd"));
    //$imagick = new \Imagick(realpath("../imagick/images/Biter_500.jpg"));
    $imagick = new \Imagick(realpath("../imagick/images/redDiscAlpha.png"));
    
    
//    
//    $imagick = new \Imagick();
    $blueDisc = new \Imagick(realpath("../imagick/images/blueDiscAlpha.png"));
    $imagick->addImage($blueDisc);
//    

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

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

    echo $result->getImageBlob();
}