Sets the image matte channel. This method is available if Imagick has been compiled against ImageMagick version 6.2.9 or newer.
I have no idea what this is meant to do, or if the example code is even close to being appropriate.
I have no idea what this is meant to do, or if the example code is even close to being appropriate.
// Example 1
function setImageMatte($alpha_type, $matte_enabled)
{
    $canvas = new Imagick();
    $canvas->newPseudoImage(640, 480, "pattern:checkerboard");
    $canvas->setImageFormat('png');

    $imagick = new \Imagick();
    $imagick->newPseudoImage(640, 480, "gradient:red-rgba(0, 0, 255, 0.1)");
    $imagick->setImageFormat('png');
    if ($alpha_type !== 0) {
        $imagick->setImageAlphaChannel($alpha_type);
    }
    $canvas->setImageMatte($matte_enabled);
    $imagick->setImageMatte($matte_enabled);

    $canvas->compositeImage($imagick, \Imagick::COMPOSITE_ATOP, 0, 0);

    header("Content-Type: image/png");
    echo $canvas->getImageBlob();
}
// Example 2 - Color
function setImageMatteColor($alpha_type, $color)
{
    $canvas = new Imagick();
    $canvas->newPseudoImage(640, 480, "pattern:checkerboard");
    $canvas->setImageFormat('png');

    $imagick = new \Imagick();
    $imagick->newPseudoImage(640, 480, "gradient:red-rgba(0, 0, 255, 0.1)");
    $imagick->setImageFormat('png');

    $imagick->setImageMatteColor($color);
    $canvas->setImageMatteColor($color);

    if ($alpha_type !== 0) {
        $imagick->setImageAlphaChannel($alpha_type);
    }

    $canvas->compositeImage($imagick, \Imagick::COMPOSITE_ATOP, 0, 0);

    header("Content-Type: image/png");
    echo $canvas->getImageBlob();
}