From 8323ae6cebde490bc29141d8dadbdbc07a1c6a4a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 31 Dec 2011 18:39:10 +0200 Subject: Fix a bug and put some comments describing changes from pull #818 --- system/libraries/Image_lib.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'system/libraries/Image_lib.php') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 7beac0ba0..c175c6740 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -169,8 +169,21 @@ class CI_Image_lib { { if (in_array($key, array('wm_font_color', 'wm_shadow_color'))) { - if ($val != '' AND preg_match('/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i', $val, $matches)) + if (preg_match('/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i', $val, $matches)) { + /* This particular line has caused a lengthy discussion + * (https://github.com/EllisLab/CodeIgniter/pull/818), so + * just to clarify: + * + * $matches[1] contains our hex color value, but it might be + * both in the full 6-length format or the shortened 3-length + * value. + * We'll later need the full version, so if we keep it if it's + * already there and if not - we'll convert to it. We can + * access string characters by their index as in an array, + * so we'll do that and use concatenation to form the final + * value: + */ $val = (strlen($matches[1]) === 6) ? '#'.$matches[1] : '#'.$matches[1][0].$matches[1][0].$matches[1][1].$matches[1][1].$matches[1][2].$matches[1][2]; @@ -1073,10 +1086,15 @@ class CI_Image_lib { if ($this->wm_use_drop_shadow) { - // Set RGB values for text and shadow - $txt_color = str_split(substr($this->wm_font_color, 1, 6)); + /* Set RGB values for text and shadow + * + * First character is #, so we don't really need it. + * Get the rest of the string and split it into 2-length + * hex values: + */ + $txt_color = str_split(substr($this->wm_font_color, 1, 6), 2); $txt_color = imagecolorclosest($src_img, hexdec($txt_color[0]), hexdec($txt_color[1]), hexdec($txt_color[2])); - $drp_color = str_split(substr($this->wm_shadow_color, 1, 6)); + $drp_color = str_split(substr($this->wm_shadow_color, 1, 6), 2); $drp_color = imagecolorclosest($src_img, hexdec($drp_color[0]), hexdec($drp_color[2]), hexdec($drp_color[3])); // Add the text to the source image -- cgit v1.2.3-24-g4f1b From bb96c8b466cb618c5fd6f004234a137011a7e374 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 31 Dec 2011 18:48:39 +0200 Subject: Fix a comment typo --- system/libraries/Image_lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Image_lib.php') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index c175c6740..5f5b5f9d5 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -178,7 +178,7 @@ class CI_Image_lib { * $matches[1] contains our hex color value, but it might be * both in the full 6-length format or the shortened 3-length * value. - * We'll later need the full version, so if we keep it if it's + * We'll later need the full version, so we keep it if it's * already there and if not - we'll convert to it. We can * access string characters by their index as in an array, * so we'll do that and use concatenation to form the final -- cgit v1.2.3-24-g4f1b From cf2ba9ee5fc50b8411eba46ddd73c59b66524fea Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 1 Jan 2012 21:57:13 +0200 Subject: Cut some comments --- system/libraries/Image_lib.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'system/libraries/Image_lib.php') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 5f5b5f9d5..fe9b8dc79 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -171,11 +171,7 @@ class CI_Image_lib { { if (preg_match('/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i', $val, $matches)) { - /* This particular line has caused a lengthy discussion - * (https://github.com/EllisLab/CodeIgniter/pull/818), so - * just to clarify: - * - * $matches[1] contains our hex color value, but it might be + /* $matches[1] contains our hex color value, but it might be * both in the full 6-length format or the shortened 3-length * value. * We'll later need the full version, so we keep it if it's -- cgit v1.2.3-24-g4f1b