From 8fc3f99e78116fbd7df9244af2ed9ef9c3a414ec Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Thu, 10 Feb 2011 15:30:52 -0600 Subject: [PATCH] Fixing bugs with Image_Imagick related to transparency in various methods. --- classes/kohana/image/imagick.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/classes/kohana/image/imagick.php b/classes/kohana/image/imagick.php index e872b91..65ba17b 100644 --- a/classes/kohana/image/imagick.php +++ b/classes/kohana/image/imagick.php @@ -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); @@ -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);