From 7001163716419bca7f60a547ed2b7f169d779dd3 Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Thu, 2 Jul 2009 11:47:54 -0500 Subject: [PATCH] Completed watermark() support in Image_GD --- classes/image/gd.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/classes/image/gd.php b/classes/image/gd.php index afe2332..9c0ff6f 100644 --- a/classes/image/gd.php +++ b/classes/image/gd.php @@ -210,7 +210,23 @@ class Image_GD extends Image { $width = imagesx($overlay); $height = imagesy($overlay); + if ($opacity < 100) + { + // Convert a range of 0-100 to 127-0 + $opacity = round(abs(($opacity * 127 / 100) - 127)); + + // Allocate transparent black + $color = imagecolorallocatealpha($overlay, 255, 255, 255, $opacity); + + // Change the transparency to black + imagelayereffect($overlay, IMG_EFFECT_OVERLAY); + + // Fill the background with transparent black + imagefilledrectangle($overlay, 0, 0, $width, $height, $color); + } + // Prevent the alpha from being lost + // This must be applied to the background! imagealphablending($this->_image, TRUE); if (imagecopy($this->_image, $overlay, $offset_x, $offset_y, 0, 0, $width, $height)) -- 2.11.4.GIT