Skip to content

Commit 99ae226

Browse files
committed
Add PNG transparency support in CI_Image_lib::text_watermark() (originally from pull bcit-ci#1317, partially fixes bcit-ci#1139)
1 parent 241a69b commit 99ae226

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

system/libraries/Image_lib.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,13 @@ public function text_watermark()
13201320
imagestring($src_img, $this->wm_font_size, $x_shad, $y_shad, $this->wm_text, $drp_color);
13211321
imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color);
13221322
}
1323+
1324+
// We can preserve transparency for PNG images
1325+
if ($this->image_type === 3)
1326+
{
1327+
imagealphablending($src_img, FALSE);
1328+
imagesavealpha($src_img, TRUE);
1329+
}
13231330
}
13241331

13251332
// Output the final image

user_guide_src/source/changelog.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,11 @@ Release Date: Not Released
172172
- Added function remove() to remove a cart item, updating with quantity of 0 seemed like a hack but has remained to retain compatibility.
173173
- :doc:`Image Manipulation library <libraries/image_lib>` changes include:
174174
- The initialize() method now only sets existing class properties.
175-
- Added support for 3-length hex color values for wm_font_color and wm_shadow_color properties, as well as validation for them.
176-
- 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.
177-
- If property maintain_ratio is set to TRUE, image_reproportion() now doesn't need both width and height to be specified.
178-
- Property maintain_ratio is now taken into account when resizing images using ImageMagick library
175+
- Added support for 3-length hex color values for *wm_font_color* and *wm_shadow_color* properties, as well as validation for them.
176+
- 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.
177+
- If property *maintain_ratio* is set to TRUE, ``image_reproportion()`` now doesn't need both width and height to be specified.
178+
- Property *maintain_ratio* is now taken into account when resizing images using ImageMagick library.
179+
- Added support for maintaining transparency for PNG images in method ``text_watermark()``.
179180
- :doc:`Form Validation library <libraries/form_validation>` changes include:
180181
- Added method error_array() to return all error messages as an array.
181182
- Added method set_data() to set an alternative data array to be validated instead of the default $_POST.

0 commit comments

Comments
 (0)