note 106051 added to function.imagick-setimagematte

From: Date: Thu, 06 Oct 2011 01:33:02 +0000
Subject: note 106051 added to function.imagick-setimagematte
Groups: php.notes 
Request: Send a blank email to php-notes+get-183654@lists.php.net to get a copy of this message
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($draw, 10, 12, 0, $text); // Draw text on the mask palette $draw->setFillColor('white'); $mask->annotateImage($draw, 11, 13, 0, $text); $mask->annotateImage($draw, 10, 12, 0, $text); $draw->setFillColor('black'); $mask->annotateImage($draw, 9, 11, 0, $text); // This is apparently needed for the mask to work $mask->setImageMatte(false); // 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 $image->setImageFormat('png'); // Output the new image header('Content-type: image/png'); echo $image; ?> ---- Server IP: 208.69.120.55 Probable Submitter: 98.253.80.56 ---- Manual Page -- http://www.php.net/manual/en/function.imagick-setimagematte.php Edit -- https://master.php.net/note/edit/106051 Del: integrated -- https://master.php.net/note/delete/106051/integrated Del: useless -- https://master.php.net/note/delete/106051/useless Del: bad code -- https://master.php.net/note/delete/106051/bad+code Del: spam -- https://master.php.net/note/delete/106051/spam Del: non-english -- https://master.php.net/note/delete/106051/non-english Del: in docs -- https://master.php.net/note/delete/106051/in+docs Del: other reasons-- https://master.php.net/note/delete/106051 Reject -- https://master.php.net/note/reject/106051 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#183654) next »