Imagick::setImageMatte

(PECL imagick 2.0.0)

Imagick::setImageMatteSets the image matte channel

Description

bool Imagick::setImageMatte ( bool $matte )

Sets the image matte channel. This method is available if Imagick has been compiled against ImageMagick version 6.2.9 or newer.

Parameters

matte

True activates the matte channel and false disables it.

Return Values

Returns TRUE on success.

Коментарии

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:

<?php

// 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
$draw->setFont('Bookman-Demi');
$draw->setFontSize(20);
$draw->setFillColor('grey70');

// Position text
$draw->setGravity(Imagick::GRAVITY_SOUTHEAST);

// Draw text on the watermark palette
$watermark->annotateImage($draw10120$text);

// Draw text on the mask palette
$draw->setFillColor('white');
$mask->annotateImage($draw11130$text);
$mask->annotateImage($draw10120$text);
$draw->setFillColor('black');
$mask->annotateImage($draw9110$text);

// This is apparently needed for the mask to work
$mask->setImageMatte(false);

// Apply mask to watermark
$watermark->compositeImage($maskImagick::COMPOSITE_COPYOPACITY00);

// Overlay watermark on image
$image->compositeImage($watermarkImagick::COMPOSITE_DISSOLVE00);

// Set output image format
$image->setImageFormat('png');

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

?>
2011-10-05 21:33:02
http://php5.kiev.ua/manual/ru/imagick.setimagematte.html

    Поддержать сайт на родительском проекте КГБ