PHPKonf: Istanbul PHP Conference 2017


(PECL imagick 2.0.0)

Imagick::setImageMatteEstablece el canal mate de la imagen


bool Imagick::setImageMatte ( bool $matte )

Establece el canal mate de la imagen. Este método está disponible si Imagick ha sido compilado con la versión 6.2.9 o superior de ImageMagick.



Si es true activa el canal mate y si es false lo deshabilita.

Valores devueltos

Devuelve TRUE en caso de éxito.

add a note add a note

User Contributed Notes 1 note

martin at psinas dot com
5 years ago
I found this method is needed when creating a font / image mask, and needs to be set to false otherwise the mask won't take effect. Here is an example:


// Create objects
$image = new Imagick('myImage.png');
$watermark = new Imagick();
$mask = new Imagick();
$draw = new ImagickDraw();

// Define dimensions
$width = $image->getImageWidth();
$height = $image->getImageHeight();

// Create some palettes
$watermark->newImage($width, $height, new ImagickPixel('grey30'));
$mask->newImage($width, $height, new ImagickPixel('black'));

// Watermark text
$text = 'Copyright';

// Set font properties

// Position text

// Draw text on the watermark palette
$watermark->annotateImage($draw, 10, 12, 0, $text);

// Draw text on the mask palette
$mask->annotateImage($draw, 11, 13, 0, $text);
$mask->annotateImage($draw, 10, 12, 0, $text);
$mask->annotateImage($draw, 9, 11, 0, $text);

// This is apparently needed for the mask to work

// Apply mask to watermark
$watermark->compositeImage($mask, Imagick::COMPOSITE_COPYOPACITY, 0, 0);

// Overlay watermark on image
$image->compositeImage($watermark, Imagick::COMPOSITE_DISSOLVE, 0, 0);

// Set output image format

// Output the new image
header('Content-type: image/png');

To Top