Explicitly cast the thumbnail dimensions into int
authorAlexander Ebert <ebert@woltlab.com>
Thu, 3 Aug 2023 11:24:21 +0000 (13:24 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 3 Aug 2023 11:24:21 +0000 (13:24 +0200)
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.

wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php

index f2e9d0d2d624615c4201aab9077b997fb12ec08c..e414f312dc01f4468734cb28f81b94d2ab1de6cc 100644 (file)
@@ -125,6 +125,9 @@ class ImagickImageAdapter implements IImageAdapter, IWebpImageAdapter
      */
     public function createThumbnail($maxWidth, $maxHeight, $preserveAspectRatio = true)
     {
+        $maxHeight = (int)$maxHeight;
+        $maxWidth = (int)$maxWidth;
+
         $thumbnail = clone $this->imagick;
 
         if ($thumbnail->getImageFormat() == 'GIF') {