diff --git a/system/Images/Handlers/GDHandler.php b/system/Images/Handlers/GDHandler.php index ab8e0b7e3dd3..e35fc726948a 100644 --- a/system/Images/Handlers/GDHandler.php +++ b/system/Images/Handlers/GDHandler.php @@ -451,7 +451,7 @@ protected function textOverlay(string $text, array $options = [], bool $isShadow * Get the rest of the string and split it into 2-length * hex values: */ - $opacity = ($options['opacity'] * 127); + $opacity = (int) ($options['opacity'] * 127); // Allow opacity to be applied to the text imagealphablending($src, true); diff --git a/tests/system/Images/GDHandlerTest.php b/tests/system/Images/GDHandlerTest.php index 76635d522354..797724fe8a26 100644 --- a/tests/system/Images/GDHandlerTest.php +++ b/tests/system/Images/GDHandlerTest.php @@ -289,7 +289,10 @@ public function testFitPositions() public function testText() { $this->handler->withFile($this->path); - $this->handler->text('vertical', ['hAlign' => 'right', 'vAlign' => 'bottom']); + $this->handler->text( + 'vertical', + ['hAlign' => 'right', 'vAlign' => 'bottom', 'opacity' => 0.5] + ); $this->assertSame(155, $this->handler->getWidth()); $this->assertSame(200, $this->handler->getHeight()); }