HomeImagickImagickDrawImagickPixelImagick Pixel IteratorImagick KernelDevelopmentTutorial Source codeReport an issue
Category
Example

Imagick::setImageMatte

← setImageMask   setImageMatteColor →
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.

Example

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();
}