HomeImagickImagickDrawImagickPixelImagick Pixel IteratorImagick KernelDevelopmentTutorial Source codeReport an issue
Category
Example

Imagick::setImageMatteColor

← setImageMatte   setImageOrientation →

Example

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