Skip to content

Commit

Permalink
Add PNG transparency support in CI_Image_lib::text_watermark() (origi…
Browse files Browse the repository at this point in the history
…nally from pull #1317, partially fixes #1139)
  • Loading branch information
narfbg committed Oct 5, 2012
1 parent 241a69b commit 99ae226
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 7 additions & 0 deletions system/libraries/Image_lib.php
Expand Up @@ -1320,6 +1320,13 @@ public function text_watermark()
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
Expand Down
9 changes: 5 additions & 4 deletions user_guide_src/source/changelog.rst
Expand Up @@ -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.
Expand Down

0 comments on commit 99ae226

Please sign in to comment.