diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-05-10 15:32:29 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-05-10 15:33:36 +0200 |
commit | 9306c2a368cc7c7da577b6199440f4abc907af7d (patch) | |
tree | e511f3bed1d6416f311dd1bab647a774c3342cfc /src | |
parent | 6e67f41152ad025e74696e7140de0f9fb0d601de (diff) | |
download | wallabag-9306c2a368cc7c7da577b6199440f4abc907af7d.tar.gz wallabag-9306c2a368cc7c7da577b6199440f4abc907af7d.tar.zst wallabag-9306c2a368cc7c7da577b6199440f4abc907af7d.zip |
Use Imagick to keep GIF animation
If Imagick is available, GIF will be saved using it to keep animation.
Otherwise the previous method will be used and the animation won't be kept.
Diffstat (limited to 'src')
-rw-r--r-- | src/Wallabag/CoreBundle/Helper/DownloadImages.php | 11 |
1 files changed, 10 insertions, 1 deletions
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': |