]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Helper/DownloadImages.php
Use Imagick to keep GIF animation
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Helper / DownloadImages.php
index cc3dcfceb7796ffcb457e749eb654680347f3dc8..bc2afc646cb79819ac05a9574ef96fe68afa7ba7 100644 (file)
@@ -135,7 +135,16 @@ class DownloadImages
 
         switch ($ext) {
             case 'gif':
-                imagegif($im, $localPath);
+                // 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);
+                } else {
+                    imagegif($im, $localPath);
+                }
+
                 $this->logger->debug('DownloadImages: Re-creating gif');
                 break;
             case 'jpeg':