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 fb00db3..c77ff31 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php @@ -105,9 +105,9 @@ protected function execute(array $arguments) { $this->getToolkit()->setResource($new_res); imagedestroy($original_res); - // GIFs need to reassign the transparent color after performing the rotate, - // but only do so, if the image already had transparency of its own, or the - // rotate added a transparent background. + // GIFs need to reassign the transparent color after performing the + // rotate, but only do so, if the image already had transparency of its + // own, or the rotate added a transparent background. if (!empty($arguments['gif_transparent_color'])) { $transparent_idx = imagecolorexactalpha($this->getToolkit()->getResource(), $arguments['gif_transparent_color']['red'], $arguments['gif_transparent_color']['green'], $arguments['gif_transparent_color']['blue'], $arguments['gif_transparent_color']['alpha']); imagecolortransparent($this->getToolkit()->getResource(), $transparent_idx); diff --git a/core/modules/system/src/Tests/Image/ToolkitGdTest.php b/core/modules/system/src/Tests/Image/ToolkitGdTest.php index faaaeb6..4e622a8 100644 --- a/core/modules/system/src/Tests/Image/ToolkitGdTest.php +++ b/core/modules/system/src/Tests/Image/ToolkitGdTest.php @@ -399,25 +399,28 @@ function testManipulations() { } } - // Test that CreateNew does not leave orphaned GD resources. + // Test that 'create_new' operation does not leave orphaned GD resources. $image = $this->imageFactory->get(drupal_get_path('module', 'simpletest') . '/files/image-test.png'); $old_res = $image->getToolkit()->getResource(); - $this->assertTrue(is_resource($old_res), 'Successfully loaded an existing image.'); + // Check if resource has been created successfully. + $this->assertTrue(is_resource($old_res)); $image->createNew(20, 20); $new_res = $image->getToolkit()->getResource(); - $this->assertFalse(is_resource($old_res), 'CreateNew destroyed the original resource.'); - $this->assertTrue(is_resource($new_res), 'CreateNew has created a new resource.'); + // Check if the original resource has been destroyed. + $this->assertFalse(is_resource($old_res)); + // Check if a new resource has been created successfully. + $this->assertTrue(is_resource($new_res)); - // Test failures of CreateNew. + // Test failures of the 'create_new' operation. $image = $this->imageFactory->get(); $image->createNew(-50, 20); - $this->assertFalse($image->isValid(), 'CreateNew with negative width fails.'); + $this->assertFalse($image->isValid(), 'create_new with negative width fails.'); $image->createNew(50, 20, 'foo'); - $this->assertFalse($image->isValid(), 'CreateNew with invalid extension fails.'); + $this->assertFalse($image->isValid(), 'create_new with invalid extension fails.'); $image->createNew(50, 20, 'gif', '#foo'); - $this->assertFalse($image->isValid(), 'CreateNew with invalid color hex string fails.'); + $this->assertFalse($image->isValid(), 'create_new with invalid color hex string fails.'); $image->createNew(50, 20, 'gif', '#ff0000'); - $this->assertTrue($image->isValid(), 'CreateNew with valid arguments validates the Image.'); + $this->assertTrue($image->isValid(), 'create_new with valid arguments validates the Image.'); } /**