From d0f3304fe7f46c51fa8c2c00f3a3def8285c61f9 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 3 Aug 2023 13:24:21 +0200 Subject: [PATCH] Explicitly cast the thumbnail dimensions into int The requested dimensions could be a result of a calculation that yields float values. `Imagick::thumbnailImage()` expects integers and will throw in PHP 8.1+ if it cannot safely cast them to int. --- .../lib/system/image/adapter/ImagickImageAdapter.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php b/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php index f2e9d0d2d62..e414f312dc0 100644 --- a/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php +++ b/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php @@ -125,6 +125,9 @@ public function createEmptyImage($width, $height) */ public function createThumbnail($maxWidth, $maxHeight, $preserveAspectRatio = true) { + $maxHeight = (int)$maxHeight; + $maxWidth = (int)$maxWidth; + $thumbnail = clone $this->imagick; if ($thumbnail->getImageFormat() == 'GIF') {