summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-02-11 12:27:01 +0100
committerAndrey Andreev <narf@devilix.net>2014-02-11 12:27:01 +0100
commite52fc267a93fd3627951ddc7c5109b573a871727 (patch)
treed10b48657e8f081c5ffe8e349882b425b821221d
parent90c54b683628ac180dd0fd9689c747def5d16b44 (diff)
Fix issue #43
-rw-r--r--system/libraries/Image_lib.php71
-rw-r--r--user_guide_src/source/changelog.rst1
2 files changed, 44 insertions, 28 deletions
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index b6a11a3a5..bb0ea7b50 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -1245,22 +1245,37 @@ class CI_Image_lib {
// offset flips itself automatically
if ($this->wm_vrt_alignment === 'B')
+ {
$this->wm_vrt_offset = $this->wm_vrt_offset * -1;
+ }
if ($this->wm_hor_alignment === 'R')
+ {
$this->wm_hor_offset = $this->wm_hor_offset * -1;
+ }
// Set font width and height
// These are calculated differently depending on
// whether we are using the true type font or not
if ($this->wm_use_truetype === TRUE)
{
- if ($this->wm_font_size === '')
+ if (empty($this->wm_font_size))
{
$this->wm_font_size = 17;
}
- $fontwidth = $this->wm_font_size-($this->wm_font_size/4);
+ if (function_exists('imagettfbbox'))
+ {
+ $temp = imagettfbbox($this->wm_font_size, 0, $this->wm_font_path, $this->wm_text);
+ $temp = $temp[2] - $temp[0];
+
+ $fontwidth = $temp / strlen($this->wm_text);
+ }
+ else
+ {
+ $fontwidth = $this->wm_font_size - ($this->wm_font_size / 4);
+ }
+
$fontheight = $this->wm_font_size;
$this->wm_vrt_offset += $this->wm_font_size;
}
@@ -1368,45 +1383,45 @@ class CI_Image_lib {
public function image_create_gd($path = '', $image_type = '')
{
if ($path === '')
+ {
$path = $this->full_src_path;
+ }
if ($image_type === '')
+ {
$image_type = $this->image_type;
+ }
switch ($image_type)
{
- case 1 :
- if ( ! function_exists('imagecreatefromgif'))
- {
- $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));
- return FALSE;
- }
+ case 1 :
+ if ( ! function_exists('imagecreatefromgif'))
+ {
+ $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));
+ return FALSE;
+ }
- return imagecreatefromgif($path);
- break;
+ return imagecreatefromgif($path);
case 2 :
- if ( ! function_exists('imagecreatefromjpeg'))
- {
- $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));
- return FALSE;
- }
+ if ( ! function_exists('imagecreatefromjpeg'))
+ {
+ $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));
+ return FALSE;
+ }
- return imagecreatefromjpeg($path);
- break;
+ return imagecreatefromjpeg($path);
case 3 :
- if ( ! function_exists('imagecreatefrompng'))
- {
- $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));
- return FALSE;
- }
-
- return imagecreatefrompng($path);
- break;
+ if ( ! function_exists('imagecreatefrompng'))
+ {
+ $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));
+ return FALSE;
+ }
+ return imagecreatefrompng($path);
+ default:
+ $this->set_error(array('imglib_unsupported_imagecreate'));
+ return FALSE;
}
-
- $this->set_error(array('imglib_unsupported_imagecreate'));
- return FALSE;
}
// --------------------------------------------------------------------
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 1e43ab23c..e08b7fee0 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -693,6 +693,7 @@ Bug fixes for 3.0
- Fixed a bug (#2771) - :doc:`Security Library <libraries/security>` method ``xss_clean()`` didn't take into account HTML5 entities.
- Fixed a bug in the :doc:`Session Library <libraries/sessions>` 'cookie' driver where authentication was not performed for encrypted cookies.
- Fixed a bug (#2856) - ODBC method ``affected_rows()`` passed an incorrect value to ``odbc_num_rows()``.
+- Fixed a bug (#43) :doc:`Image Manipulation Library <libraries/image_lib>` method ``text_watermark()`` didn't properly determine watermark placement.
Version 2.1.4
=============