PHP Imagick GIF Animation Is Not Preserved

烂漫一生 提交于 2019-12-13 19:55:16

问题


I am having a bit up trouble upload gifs and keeping their animation. My code looks like this:

$image = new Imagick($data['file']);
$object -> uploadFile('test.gif', $image -> getImageBlob());

And the gif goes not seem to be preserved when the getImageBlob() is used. Ive event tried:

$image = new Imagick($data['file']);
$image = $image->coalesceImages(); 
$image = $image->deconstructImages(); 
$object -> uploadFile('test.gif', $image -> getImageBlob());

Is there way I can preseve the gif when using getImageBlob()?


回答1:


Try Imagick::getImagesBlob instead of Imagick::getImageBlob. getImagesBlob will return the sequence of loaded images, as opposed to just a single image; in this case, the each frame in the GIF.

A quick check with PHP 5.5.7 and PECL imagick 3.1.2 reveals two different behaviors:

$image = new Imagick('test.gif');
var_dump(strlen($image->getImagesBlob())); // int(4316519)
var_dump(strlen($image->getImageBlob()));  // int(61413)


来源:https://stackoverflow.com/questions/20361458/php-imagick-gif-animation-is-not-preserved

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!