diff --git a/modules/simpletest/tests/image.test b/modules/simpletest/tests/image.test index 72090c6..cb346c1 100644 --- a/modules/simpletest/tests/image.test +++ b/modules/simpletest/tests/image.test @@ -334,13 +334,6 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase { // Systems using non-bundled GD2 don't have imagerotate. Test if available. if (function_exists('imagerotate')) { $operations += array( - 'rotate_5' => array( - 'function' => 'rotate', - 'arguments' => array(5, 0xFF00FF), // Fuchsia background. - 'width' => 42, - 'height' => 24, - 'corners' => array_fill(0, 4, $this->fuchsia), - ), 'rotate_90' => array( 'function' => 'rotate', 'arguments' => array(90, 0xFF00FF), // Fuchsia background. @@ -348,13 +341,6 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase { 'height' => 40, 'corners' => array($this->fuchsia, $this->red, $this->green, $this->blue), ), - 'rotate_transparent_5' => array( - 'function' => 'rotate', - 'arguments' => array(5), - 'width' => 42, - 'height' => 24, - 'corners' => array_fill(0, 4, $this->transparent), - ), 'rotate_transparent_90' => array( 'function' => 'rotate', 'arguments' => array(90), @@ -363,6 +349,49 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase { 'corners' => array($this->transparent, $this->red, $this->green, $this->blue), ), ); + // As of PHP version 5.5, GD uses a different algorithm to rotate images + // than version 5.4 and below, resulting in different dimensions. + // See https://bugs.php.net/bug.php?id=65148). + // For the 40x20 test images, the dimensions resulting from rotation will + // be 1 pixel smaller in both width and height in PHP 5.5 and above. + // @todo: If and when the PHP bug gets solved, add an upper limit + // version check. + if (version_compare(PHP_VERSION, '5.5', '>=')) { + $operations += array( + 'rotate_5' => array( + 'function' => 'rotate', + 'arguments' => array(5, 0xFF00FF), // Fuchsia background. + 'width' => 41, + 'height' => 23, + 'corners' => array_fill(0, 4, $this->fuchsia), + ), + 'rotate_transparent_5' => array( + 'function' => 'rotate', + 'arguments' => array(5), + 'width' => 41, + 'height' => 23, + 'corners' => array_fill(0, 4, $this->transparent), + ), + ); + } + else { + $operations += array( + 'rotate_5' => array( + 'function' => 'rotate', + 'arguments' => array(5, 0xFF00FF), // Fuchsia background. + 'width' => 42, + 'height' => 24, + 'corners' => array_fill(0, 4, $this->fuchsia), + ), + 'rotate_transparent_5' => array( + 'function' => 'rotate', + 'arguments' => array(5), + 'width' => 42, + 'height' => 24, + 'corners' => array_fill(0, 4, $this->transparent), + ), + ); + } } // Systems using non-bundled GD2 don't have imagefilter. Test if available. @@ -419,17 +448,6 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase { $correct_dimensions_object = TRUE; $correct_colors = TRUE; - // 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 - // version check. - if (version_compare(PHP_VERSION, '5.5', '>=') && $values['function'] === 'rotate' && $values['arguments'][0] % 90 != 0) { - $values['height']--; - $values['width']--; - } if (imagesy($image->resource) != $values['height'] || imagesx($image->resource) != $values['width']) { $correct_dimensions_real = FALSE; } diff --git a/modules/system/image.gd.inc b/modules/system/image.gd.inc index 5bd1625..6552a37 100644 --- a/modules/system/image.gd.inc +++ b/modules/system/image.gd.inc @@ -123,7 +123,7 @@ function image_gd_rotate(stdClass $image, $degrees, $background = NULL) { if (isset($background)) { $background = image_dec_to_rgba($background); - $background['alpha'] /= 2; + $background['alpha'] = 0; } else { // Background color is not specified: use transparent white as background.