Skip to content

Commit

Permalink
Fixing bugs with Image_Imagick related to transparency in various met…
Browse files Browse the repository at this point in the history
…hods.
  • Loading branch information
Woody Gilk committed Feb 10, 2011
1 parent 480ff7c commit 8fc3f99
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions classes/kohana/image/imagick.php
Expand Up @@ -204,17 +204,20 @@ protected function _do_watermark(Image $image, $offset_x, $offset_y, $opacity)
$watermark = new Imagick;
$watermark->readImageBlob($image->render(), $image->file);

if ( ! $watermark->getImageAlphaChannel())
if ($watermark->getImageAlphaChannel() !== Imagick::ALPHACHANNEL_ACTIVATE)
{
// Force the image to have an alpha channel
$watermark->setImageAlphaChannel(Imagick::ALPHACHANNEL_SET);
$watermark->setImageAlphaChannel(Imagick::ALPHACHANNEL_OPAQUE);
}

// NOTE: Using setImageOpacity will destroy current alpha channels!
$watermark->evaluateImage(Imagick::EVALUATE_MULTIPLY, $opacity / 100, Imagick::CHANNEL_ALPHA);
if ($opacity < 100)
{
// NOTE: Using setImageOpacity will destroy current alpha channels!
$watermark->evaluateImage(Imagick::EVALUATE_MULTIPLY, $opacity / 100, Imagick::CHANNEL_ALPHA);
}

// Match the colorspace between the two images before compositing
$watermark->setColorspace($this->im->getColorspace());
// $watermark->setColorspace($this->im->getColorspace());

// Apply the watermark to the image
return $this->im->compositeImage($watermark, Imagick::COMPOSITE_DISSOLVE, $offset_x, $offset_y);
Expand Down Expand Up @@ -283,9 +286,6 @@ protected function _do_render($type, $quality)
// Get the image format and type
list($format, $type) = $this->_get_imagetype($type);

// Flatten the current image
$this->im = $this->im->flattenImages();

// Set the output image type
$this->im->setFormat($format);

Expand Down

0 comments on commit 8fc3f99

Please sign in to comment.