From f3845be39fe154e08b5bd6cc2a162fc119a69edf Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Tue, 28 Mar 2023 15:06:05 +0200 Subject: [PATCH] Fix GD2 for #1009 --- snappymail/v/0.0.0/app/libraries/snappymail/image/gd2.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/snappymail/v/0.0.0/app/libraries/snappymail/image/gd2.php b/snappymail/v/0.0.0/app/libraries/snappymail/image/gd2.php index b4dd61aab..3f496b3f8 100644 --- a/snappymail/v/0.0.0/app/libraries/snappymail/image/gd2.php +++ b/snappymail/v/0.0.0/app/libraries/snappymail/image/gd2.php @@ -50,7 +50,8 @@ class GD2 implements \SnappyMail\Image } $gd2 = new static(); $gd2->img = \imagecreatefromstring($data); - if (!\is_resource($gd2->img)) { + // resource or PHP8 GdImage + if (!$gd2->img) { throw new \InvalidArgumentException('Failed to load image'); } $gd2->file = 'blob'; @@ -223,7 +224,7 @@ class GD2 implements \SnappyMail\Image /** rotate clockwise */ if (!\function_exists('imagerotate')) { require __DIR__ . '/gd2/imagerotate.inc'; } $tmp_img = \imagerotate($this->img, $degrees * -1, 0); - if (!\is_resource($tmp_img)) { return false; } + if (!$tmp_img) { return false; } \imagedestroy($this->img); $this->img = $tmp_img; return true; @@ -240,7 +241,7 @@ class GD2 implements \SnappyMail\Image if (!$width || ($bestfit && $tx < $ty)) { $width = \round($x / $ty); } if (!$height || ($bestfit && $tx > $ty)) { $height = \round($y / $tx); } $tmp_img = $this->create_image($width, $height); - if (!\is_resource($tmp_img)) { return false; } + if (!$tmp_img) { return false; } \imagealphablending($tmp_img, false); if (!\imagecopyresampled($tmp_img, $this->img, 0, 0, 0, 0, $width, $height, $x, $y)) { if (!\imagecopyresized($tmp_img, $this->img, 0, 0, 0, 0, $width, $height, $x, $y)) {