From 783b05cbb19f190dd0acb9fbcaf440135826d82e Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 21 May 2022 18:44:03 +0200 Subject: [PATCH 1/2] Fix unsupported animated webp parsing --- src/Object/Image.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/Object/Image.php b/src/Object/Image.php index 5cef75180b..2d62aea46c 100644 --- a/src/Object/Image.php +++ b/src/Object/Image.php @@ -159,15 +159,24 @@ class Image } $this->valid = false; - $this->image = @imagecreatefromstring($data); - if ($this->image !== false) { - $this->width = imagesx($this->image); - $this->height = imagesy($this->image); - $this->valid = true; - imagealphablending($this->image, false); - imagesavealpha($this->image, true); + try { + $this->image = @imagecreatefromstring($data); + if ($this->image !== false) { + $this->width = imagesx($this->image); + $this->height = imagesy($this->image); + $this->valid = true; + imagealphablending($this->image, false); + imagesavealpha($this->image, true); - return true; + return true; + } + } catch (\Throwable $error) { + /** @see https://github.com/php/doc-en/commit/d09a881a8e9059d11e756ee59d75bf404d6941ed */ + if (strstr($error->getMessage(), "gd-webp cannot allocate temporary buffer")) { + DI::logger()->notice('Image is probably a kind of unsupported, animated GID', ['error' => $error]); + } else { + DI::logger()->warning('Unexpected throwable.', ['error' => $error]); + } } return false; From 218fc0c20d35d0265ee213af46aa7a0c0edae8d4 Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 21 May 2022 18:51:03 +0200 Subject: [PATCH 2/2] Fix unsupported animated webp parsing --- src/Object/Image.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Object/Image.php b/src/Object/Image.php index 2d62aea46c..16206963b4 100644 --- a/src/Object/Image.php +++ b/src/Object/Image.php @@ -173,7 +173,7 @@ class Image } catch (\Throwable $error) { /** @see https://github.com/php/doc-en/commit/d09a881a8e9059d11e756ee59d75bf404d6941ed */ if (strstr($error->getMessage(), "gd-webp cannot allocate temporary buffer")) { - DI::logger()->notice('Image is probably a kind of unsupported, animated GID', ['error' => $error]); + DI::logger()->notice('Image is probably animated and therefore unsupported', ['error' => $error]); } else { DI::logger()->warning('Unexpected throwable.', ['error' => $error]); }