summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-10-05 14:14:30 +0200
committerAndrey Andreev <narf@bofh.bg>2012-10-05 14:14:30 +0200
commit99ae226607fff411bae3b69475bd1b0e3981d563 (patch)
tree4ba675b36bc1cebc3495a9a0e901cce77d103bee
parent241a69be96de350b18d875304eb1e361b710e148 (diff)
Add PNG transparency support in CI_Image_lib::text_watermark() (originally from pull #1317, partially fixes #1139)
-rw-r--r--system/libraries/Image_lib.php7
-rw-r--r--user_guide_src/source/changelog.rst9
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 <libraries/image_lib>` 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 <libraries/form_validation>` 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.