forked from wallabag/wallabag
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.
This commit is contained in:
@ -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':
|
||||
|
||||
Reference in New Issue
Block a user