mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-23 16:10:28 +00:00
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:
parent
6e67f41152
commit
9306c2a368
2 changed files with 13 additions and 1 deletions
|
@ -103,6 +103,9 @@
|
||||||
"phpstan/phpstan-symfony": "^0.11.0",
|
"phpstan/phpstan-symfony": "^0.11.0",
|
||||||
"phpstan/phpstan-doctrine": "^0.11.0"
|
"phpstan/phpstan-doctrine": "^0.11.0"
|
||||||
},
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-imagick": "To keep GIF animation when downloading image is enabled"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"post-cmd": [
|
"post-cmd": [
|
||||||
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
|
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
|
||||||
|
|
|
@ -135,7 +135,16 @@ class DownloadImages
|
||||||
|
|
||||||
switch ($ext) {
|
switch ($ext) {
|
||||||
case 'gif':
|
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);
|
||||||
|
} else {
|
||||||
imagegif($im, $localPath);
|
imagegif($im, $localPath);
|
||||||
|
}
|
||||||
|
|
||||||
$this->logger->debug('DownloadImages: Re-creating gif');
|
$this->logger->debug('DownloadImages: Re-creating gif');
|
||||||
break;
|
break;
|
||||||
case 'jpeg':
|
case 'jpeg':
|
||||||
|
|
Loading…
Reference in a new issue