From b53cdce73257d5cbff52d92ab8a29f7067f221f1 Mon Sep 17 00:00:00 2001 From: Franck ALARY Date: Sun, 6 Aug 2023 09:04:32 +0200 Subject: [PATCH] Fix php8 warnings --- src/Image.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Image.php b/src/Image.php index baf5e12..89ff0a4 100644 --- a/src/Image.php +++ b/src/Image.php @@ -380,7 +380,7 @@ private function convertPosX($posX, int $width = 0): int case static::ALIGN_LEFT: return 0; case static::ALIGN_CENTER: - return $this->width / 2 - $width / 2; + return \round($this->width / 2 - $width / 2); case static::ALIGN_RIGHT: return $this->width - $width; } @@ -400,7 +400,7 @@ private function convertPosY($posY, int $height = 0): int case static::ALIGN_TOP: return 0; case static::ALIGN_MIDDLE: - return $this->height / 2 - $height / 2; + return \round($this->height / 2 - $height / 2); case static::ALIGN_BOTTOM: return $this->height - $height; } @@ -960,7 +960,7 @@ public function writeTextAndGetBoundingBox(string $string, string $fontPath, flo private function imagettftextWithSpacing($image, float $size, float $angle, float $x, float $y, int $color, string $font, string $text, float $spacing = 0) { if ($spacing == 0) { - return \imagettftext($image, $size, $angle, $x, $y, $color, $font, $text); + return \imagettftext($image, $size, $angle, \round($x), \round($y), $color, $font, $text); } else { $length = \mb_strlen($text); @@ -975,7 +975,7 @@ private function imagettftextWithSpacing($image, float $size, float $angle, floa for ($i = 0; $i < $length; ++$i) { $char = \mb_substr($text, $i, 1); - \imagettftext($image, $size, $angle, $letterPos['x'], $letterPos['y'], $color, $font, $char); + \imagettftext($image, $size, $angle, \round($letterPos['x']), \round($letterPos['y']), $color, $font, $char); $bbox = \imagettfbbox($size, 0, $font, $char); $letterPos = Geometry2D::getDstXY($letterPos['x'], $letterPos['y'], $angle, $spacing + $bbox[2]);