]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Fallback to default solution if Imagick fails 3955/head
authorJeremy Benoist <jeremy.benoist@gmail.com>
Fri, 10 May 2019 14:52:01 +0000 (16:52 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Fri, 10 May 2019 14:52:01 +0000 (16:52 +0200)
src/Wallabag/CoreBundle/Helper/DownloadImages.php

index bc2afc646cb79819ac05a9574ef96fe68afa7ba7..9a7e9828594492bca5bb8286e82e7f31da8f3763 100644 (file)
@@ -137,10 +137,15 @@ class DownloadImages
             case 'gif':
                 // use Imagick if available to keep GIF animation
                 if (class_exists('\\Imagick')) {
-                    $imagick = new \Imagick();
-                    $imagick->readImageBlob($res->getBody());
-                    $imagick->setImageFormat('gif');
-                    $imagick->writeImages($localPath, true);
+                    try {
+                        $imagick = new \Imagick();
+                        $imagick->readImageBlob($res->getBody());
+                        $imagick->setImageFormat('gif');
+                        $imagick->writeImages($localPath, true);
+                    } catch (\Exception $e) {
+                        // if Imagick fail, fallback to the default solution
+                        imagegif($im, $localPath);
+                    }
                 } else {
                     imagegif($im, $localPath);
                 }