Skip to content

Commit

Permalink
fix: Implicit conversion from float to int loses precision
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed May 5, 2022
1 parent 95437a4 commit 3b689cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion system/Images/Handlers/GDHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion tests/system/Images/GDHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down

0 comments on commit 3b689cc

Please sign in to comment.