diff options
-rw-r--r-- | composer.json | 3 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Helper/DownloadImages.php | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/composer.json b/composer.json index b28404e3..b1c144c7 100644 --- a/composer.json +++ b/composer.json | |||
@@ -103,6 +103,9 @@ | |||
103 | "phpstan/phpstan-symfony": "^0.11.0", | 103 | "phpstan/phpstan-symfony": "^0.11.0", |
104 | "phpstan/phpstan-doctrine": "^0.11.0" | 104 | "phpstan/phpstan-doctrine": "^0.11.0" |
105 | }, | 105 | }, |
106 | "suggest": { | ||
107 | "ext-imagick": "To keep GIF animation when downloading image is enabled" | ||
108 | }, | ||
106 | "scripts": { | 109 | "scripts": { |
107 | "post-cmd": [ | 110 | "post-cmd": [ |
108 | "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", | 111 | "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", |
diff --git a/src/Wallabag/CoreBundle/Helper/DownloadImages.php b/src/Wallabag/CoreBundle/Helper/DownloadImages.php index cc3dcfce..bc2afc64 100644 --- a/src/Wallabag/CoreBundle/Helper/DownloadImages.php +++ b/src/Wallabag/CoreBundle/Helper/DownloadImages.php | |||
@@ -135,7 +135,16 @@ class DownloadImages | |||
135 | 135 | ||
136 | switch ($ext) { | 136 | switch ($ext) { |
137 | case 'gif': | 137 | case 'gif': |
138 | imagegif($im, $localPath); | 138 | // use Imagick if available to keep GIF animation |
139 | if (class_exists('\\Imagick')) { | ||
140 | $imagick = new \Imagick(); | ||
141 | $imagick->readImageBlob($res->getBody()); | ||
142 | $imagick->setImageFormat('gif'); | ||
143 | $imagick->writeImages($localPath, true); | ||
144 | } else { | ||
145 | imagegif($im, $localPath); | ||
146 | } | ||
147 | |||
139 | $this->logger->debug('DownloadImages: Re-creating gif'); | 148 | $this->logger->debug('DownloadImages: Re-creating gif'); |
140 | break; | 149 | break; |
141 | case 'jpeg': | 150 | case 'jpeg': |