update page now

Voting

: two plus two?
(Example: nine)

The Note You're Voting On

php at lfbittencourt dot com
13 years ago
Do you want a color overlay with TRUE opacity control? Try this:

<?php

class YourImagick extends Imagick
{
    public function colorize($color, $alpha = 1)
    {
        $draw = new ImagickDraw();

        $draw->setFillColor($color);

        if (is_float($alpha)) {
            $draw->setFillAlpha($alpha);
        }

        $geometry = $this->getImageGeometry();
        $width = $geometry['width'];
        $height = $geometry['height'];

        $draw->rectangle(0, 0, $width, $height);

        $this->drawImage($draw);
    }
}

?>

How to use:

<?php

$imagick = new YourImagick('example.png');

$imagick->colorize('#ffcc00', 0.35);

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

echo $source;

?>

<< Back to user notes page

To Top