]> git.mxchange.org Git - friendica.git/blobdiff - src/Object/Image.php
Merge pull request #11643 from annando/avatar-path
[friendica.git] / src / Object / Image.php
index 5cef75180bdb2949f4fac96c903a07bb81d28342..16206963b47c8b3664a36faa6f27b9df675456cc 100644 (file)
@@ -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);
-
-                       return 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;
+                       }
+               } 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 animated and therefore unsupported', ['error' => $error]);
+                       } else {
+                               DI::logger()->warning('Unexpected throwable.', ['error' => $error]);
+                       }
                }
 
                return false;