Skip to content

Commit 3b689cc

Browse files
committed
fix: Implicit conversion from float to int loses precision
1 parent 95437a4 commit 3b689cc

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

system/Images/Handlers/GDHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ protected function textOverlay(string $text, array $options = [], bool $isShadow
451451
* Get the rest of the string and split it into 2-length
452452
* hex values:
453453
*/
454-
$opacity = ($options['opacity'] * 127);
454+
$opacity = (int) ($options['opacity'] * 127);
455455

456456
// Allow opacity to be applied to the text
457457
imagealphablending($src, true);

tests/system/Images/GDHandlerTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,10 @@ public function testFitPositions()
289289
public function testText()
290290
{
291291
$this->handler->withFile($this->path);
292-
$this->handler->text('vertical', ['hAlign' => 'right', 'vAlign' => 'bottom']);
292+
$this->handler->text(
293+
'vertical',
294+
['hAlign' => 'right', 'vAlign' => 'bottom', 'opacity' => 0.5]
295+
);
293296
$this->assertSame(155, $this->handler->getWidth());
294297
$this->assertSame(200, $this->handler->getHeight());
295298
}

0 commit comments

Comments
 (0)