From 4ecb410b3c26d5b2ebcd44379b4133af34792b4f Mon Sep 17 00:00:00 2001 From: flashwave Date: Wed, 6 Jul 2022 18:52:45 +0000 Subject: [PATCH] Fixed thumbnailing. --- src/Upload.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Upload.php b/src/Upload.php index 7aef6dd..25b2dbe 100644 --- a/src/Upload.php +++ b/src/Upload.php @@ -378,11 +378,11 @@ final class Upload implements JsonSerializable { $height = $imagick->getImageHeight(); if ($width > $height) { - $resizeWidth = $width * $thumbRes / $height; + $resizeWidth = ceil($width * $thumbRes / $height); $resizeHeight = $thumbRes; } else { $resizeWidth = $thumbRes; - $resizeHeight = $height * $thumbRes / $width; + $resizeHeight = ceil($height * $thumbRes / $width); } $imagick->resizeImage( @@ -393,8 +393,8 @@ final class Upload implements JsonSerializable { $imagick->cropImage( $thumbRes, $thumbRes, - ($resizeWidth - $thumbRes) / 2, - ($resizeHeight - $thumbRes) / 2 + ceil(($resizeWidth - $thumbRes) / 2), + ceil(($resizeHeight - $thumbRes) / 2) ); $imagick->writeImage($this->getThumbPath());