diff --git a/includes/image.inc b/includes/image.inc index e30a338..a6e7ab9 100644 --- a/includes/image.inc +++ b/includes/image.inc @@ -290,12 +290,12 @@ function image_resize(stdClass $image, $width, $height) { * An image object returned by image_load(). * @param $degrees * The number of (clockwise) degrees to rotate the image. - * @param $background - * An hexadecimal integer specifying the background color to use for the - * uncovered area of the image after the rotation. E.g. 0x000000 for black, - * 0xff00ff for magenta, and 0xffffff for white. For images that support - * transparency, this will default to transparent. Otherwise it will - * be white. + * @param int $background + * (optional) A 24 bit or 32 bit ARGB value specifying the background color + * to use for the uncovered area of the image after the rotation (for + * example, 0 for black, 16711935 for fuchsia, and 16777215 for white). For + * images that support transparency, this will default to transparent. + * Otherwise it will be white. * * @return * TRUE on success, FALSE on failure. @@ -431,5 +431,23 @@ function image_save(stdClass $image, $destination = NULL) { } /** + * Converts a 24 bit RGB or 32 bit ARGB value to an RGBA array. + * + * @param int $argb + * The color code to convert. + * + * @return array + * An array containing the values for 'red', 'green', 'blue', and 'alpha'. + */ +function image_dec_to_rgba($argb) { + return array( + 'red' => $argb >> 16 & 0xFF, + 'green' => $argb >> 8 & 0xFF, + 'blue' => $argb & 0xFF, + 'alpha' => $argb >> 24 & 0xFF, + ); +} + +/** * @} End of "defgroup image". */ diff --git a/modules/image/image.module b/modules/image/image.module index 2122e05..dab8836 100644 --- a/modules/image/image.module +++ b/modules/image/image.module @@ -1413,21 +1413,3 @@ function image_filter_keyword($value, $current_pixels, $new_pixels) { function _image_effect_definitions_sort($a, $b) { return strcasecmp($a['name'], $b['name']); } - -/** - * Converts a 24 bit RGB or 32 bit ARGB value to an RGBA array. - * - * @param int $argb - * The color code to convert. - * - * @return array - * An array containing the values for 'red', 'green', 'blue', 'alpha'. - */ -function _image_dec_to_rgba($argb) { - return array( - 'red' => $argb >> 16 & 0xFF, - 'green' => $argb >> 8 & 0xFF, - 'blue' => $argb & 0xFF, - 'alpha' => $argb >> 24 & 0xFF, - ); -} diff --git a/modules/simpletest/tests/image.test b/modules/simpletest/tests/image.test index f742cda..72090c6 100644 --- a/modules/simpletest/tests/image.test +++ b/modules/simpletest/tests/image.test @@ -419,16 +419,13 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase { $correct_dimensions_object = TRUE; $correct_colors = TRUE; - // PHP 5.5 GD bug: https://bugs.php.net/bug.php?id=65148. PHP 5.5 GD - // rotates differently then it did in PHP 5.4 resulting in different - // dimensions then what math teaches us. For the test images, the + // PHP 5.5 GD rotates differently than it did in PHP 5.4, resulting in + // different dimensions than what would normally be expected (see + // https://bugs.php.net/bug.php?id=65148). For the test images, the // dimensions will be 1 pixel smaller in both dimensions (though other - // tests have shown a difference of 0 to 3 pixels in both dimensions. - // @todo: if and when the PHP bug gets solved, add an upper limit + // tests have shown a difference of 0 to 3 pixels in both dimensions). + // @todo: If and when the PHP bug gets solved, add an upper limit // version check. - // @todo: in [#1551686] the dimension calculations for rotation are - // reworked. That issue should also check if these tests can be made - // more robust. if (version_compare(PHP_VERSION, '5.5', '>=') && $values['function'] === 'rotate' && $values['arguments'][0] % 90 != 0) { $values['height']--; $values['width']--; diff --git a/modules/system/image.gd.inc b/modules/system/image.gd.inc index 28ab3f0..5bd1625 100644 --- a/modules/system/image.gd.inc +++ b/modules/system/image.gd.inc @@ -99,11 +99,11 @@ function image_gd_resize(stdClass $image, $width, $height) { * @param $degrees * The number of (clockwise) degrees to rotate the image. * @param int $background - * An 24 bit or 32 bit ARGB value specifying the background color to use for - * the uncovered area of the image after the rotation. E.g. 0 for black, - * 16711935 for fuchsia, and 16777215 for white. For images that support - * transparency, this will default to transparent. Otherwise it will - * be white. + * (optional) A 24 bit or 32 bit ARGB value specifying the background color + * to use for the uncovered area of the image after the rotation (for + * example, 0 for black, 16711935 for fuchsia, and 16777215 for white). For + * images that support transparency, this will default to transparent. + * Otherwise it will be white. * @return * TRUE or FALSE, based on success. * @@ -122,7 +122,7 @@ function image_gd_rotate(stdClass $image, $degrees, $background = NULL) { $degrees -= floor($degrees / 360) * 360; if (isset($background)) { - $background = _image_dec_to_rgba($background); + $background = image_dec_to_rgba($background); $background['alpha'] /= 2; } else {