From 82dbef988e356baa5d73993a1351bcb6c0959269 Mon Sep 17 00:00:00 2001 From: "J.Brabec" <59865811+shadowx-jb@users.noreply.github.com> Date: Mon, 12 Dec 2022 15:31:53 +0100 Subject: [PATCH] Implicit conversion from float 50.800000000000004 to int loses precision (#310) --- src/claviska/SimpleImage.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/claviska/SimpleImage.php b/src/claviska/SimpleImage.php index 3379467..7c95316 100644 --- a/src/claviska/SimpleImage.php +++ b/src/claviska/SimpleImage.php @@ -63,7 +63,7 @@ public function __construct($image = '', $flags = []) { $this->flags = [ "sslVerify" => true // Skip SSL peer validation ]; - + // Override default flag values. foreach($flags as $flag => $value) { $this->setFlag($flag, $value); @@ -206,7 +206,7 @@ public function fromFile($file) { $alpha = imagecolorallocatealpha($gif, 0, 0, 0, 127); imagecolortransparent($gif, $alpha); imagefill($gif, 0, 0, $alpha); - + imagecopy($this->image, $gif, 0, 0, 0, 0, $width, $height); imagedestroy($gif); break; @@ -526,7 +526,7 @@ protected static function imageCopyMergeAlpha($dstIm, $srcIm, $dstX, $dstY, $src if($pct < 100) { // Disable alpha blending and "colorize" the image using a transparent color imagealphablending($srcIm, false); - imagefilter($srcIm, IMG_FILTER_COLORIZE, 0, 0, 0, 127 * ((100 - $pct) / 100)); + imagefilter($srcIm, IMG_FILTER_COLORIZE, 0, 0, 0, round(127 * ((100 - $pct) / 100))); } imagecopy($dstIm, $srcIm, (int) $dstX, (int) $dstY, (int) $srcX, (int) $srcY, (int) $srcW, (int) $srcH);