This commit is contained in:
the-djmaze 2023-03-28 15:06:05 +02:00
parent dd74759adc
commit f3845be39f

View file

@ -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)) {