diff --git a/core/modules/image/src/Tests/ImageDimensionsTest.php b/core/modules/image/src/Tests/ImageDimensionsTest.php index 79b6fb5..48016ea 100644 --- a/core/modules/image/src/Tests/ImageDimensionsTest.php +++ b/core/modules/image/src/Tests/ImageDimensionsTest.php @@ -100,8 +100,8 @@ function testImageDimensions() { $this->assertResponse(200, 'Image was generated at the URL.'); $this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.'); $image_file = $image_factory->get($generated_uri); - $this->assertTrue($image_file->getWidth() == 60 || $image_file->getWidth() == 59); - $this->assertTrue($image_file->getHeight() == 120 || $image_file->getHeight() == 119); + $this->assertEqual($image_file->getWidth(), 60); + $this->assertEqual($image_file->getHeight(), 120); // Scale an image that is higher than it is wide (rotated by previous effect). $effect = array( diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php index fd48d64..6a8dbf2 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php @@ -62,9 +62,10 @@ protected function execute(ImageInterface $image, array $arguments) { else { // Get the current transparent color. $arguments['background'] = imagecolortransparent($this->getToolkit()->getResource()); - // If the image has no current transparent color, define one. - if ($arguments['background'] === -1) { - $arguments['background'] = imagecolorallocatealpha($this->getToolkit()->getResource(), 0, 0, 0, 127); + + // If no transparent colors, use white. + if ($arguments['background'] == 0) { + $arguments['background'] = imagecolorallocatealpha($this->getToolkit()->getResource(), 255, 255, 255, 0); } } @@ -72,7 +73,7 @@ protected function execute(ImageInterface $image, array $arguments) { // transparency flags. For GIF images, keep a record of the transparent color. if ($this->getToolkit()->getType() == IMAGETYPE_GIF) { $transparent_index = imagecolortransparent($this->getToolkit()->getResource()); - if ($transparent_index !== -1) { + if ($transparent_index != 0) { $transparent_gif_color = imagecolorsforindex($this->getToolkit()->getResource(), $transparent_index); } } diff --git a/core/modules/system/src/Tests/Image/ToolkitGdTest.php b/core/modules/system/src/Tests/Image/ToolkitGdTest.php index 1438714..1ba8c19 100644 --- a/core/modules/system/src/Tests/Image/ToolkitGdTest.php +++ b/core/modules/system/src/Tests/Image/ToolkitGdTest.php @@ -262,17 +262,9 @@ function testManipulations() { $correct_dimensions_real = TRUE; $correct_dimensions_object = TRUE; - // Check the real dimensions of the image first. On PHP 5.5, the - // resulting image of a rotate operation may be 1 pixel smaller in - // both dimensions. + // Check the real dimensions of the image first. if (imagesy($toolkit->getResource()) != $values['height'] || imagesx($toolkit->getResource()) != $values['width']) { - if ($values['function'] == 'rotate' && imagesy($toolkit->getResource()) == $values['height'] - 1 && imagesx($toolkit->getResource()) == $values['width'] - 1) { - $values['height']--; - $values['width']--; - } - else { - $correct_dimensions_real = FALSE; - } + $correct_dimensions_real = FALSE; } // Check that the image object has an accurate record of the dimensions. @@ -313,9 +305,6 @@ function testManipulations() { } $color = $this->getPixelColor($image, $x, $y); $correct_colors = $this->colorsAreEqual($color, $corner); - if (!$correct_colors) { - $i = 3; - } $this->assertTrue($correct_colors, String::format('Image %file object after %action action has the correct color placement at corner %corner.', array('%file' => $file, '%action' => $op, '%corner' => $key))); } }