From 99ae226607fff411bae3b69475bd1b0e3981d563 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 5 Oct 2012 15:14:30 +0300 Subject: Add PNG transparency support in CI_Image_lib::text_watermark() (originally from pull #1317, partially fixes #1139) --- system/libraries/Image_lib.php | 7 +++++++ user_guide_src/source/changelog.rst | 9 +++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 899b995d4..ef4187847 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -1320,6 +1320,13 @@ class CI_Image_lib { imagestring($src_img, $this->wm_font_size, $x_shad, $y_shad, $this->wm_text, $drp_color); imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color); } + + // We can preserve transparency for PNG images + if ($this->image_type === 3) + { + imagealphablending($src_img, FALSE); + imagesavealpha($src_img, TRUE); + } } // Output the final image diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index e2f780c65..b3fbe718b 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -172,10 +172,11 @@ Release Date: Not Released - Added function remove() to remove a cart item, updating with quantity of 0 seemed like a hack but has remained to retain compatibility. - :doc:`Image Manipulation library ` changes include: - The initialize() method now only sets existing class properties. - - Added support for 3-length hex color values for wm_font_color and wm_shadow_color properties, as well as validation for them. - - Class properties wm_font_color, wm_shadow_color and wm_use_drop_shadow are now protected, to avoid breaking the text_watermark() method if they are set manually after initialization. - - If property maintain_ratio is set to TRUE, image_reproportion() now doesn't need both width and height to be specified. - - Property maintain_ratio is now taken into account when resizing images using ImageMagick library + - Added support for 3-length hex color values for *wm_font_color* and *wm_shadow_color* properties, as well as validation for them. + - Class properties *wm_font_color*, *wm_shadow_color* and *wm_use_drop_shadow* are now protected, to avoid breaking the ``text_watermark()`` method if they are set manually after initialization. + - If property *maintain_ratio* is set to TRUE, ``image_reproportion()`` now doesn't need both width and height to be specified. + - Property *maintain_ratio* is now taken into account when resizing images using ImageMagick library. + - Added support for maintaining transparency for PNG images in method ``text_watermark()``. - :doc:`Form Validation library ` changes include: - Added method error_array() to return all error messages as an array. - Added method set_data() to set an alternative data array to be validated instead of the default $_POST. -- cgit v1.2.3-24-g4f1b