file_get_contents 动画 gif

问题描述

对动画 GIF (https://media.tenor.com/images/4f20af75f32887384aab7e49c37537ae/tenor.gif) 的 URL 调用 file_get_contents 并将此内容保存到本地文件,将丢失动画。

animation lost

如何保留动画?

谢谢

解决方法

$imgData = file_get_contents('https://media.tenor.com/images/4f20af75f32887384aab7e49c37537ae/tenor.gif');
file_put_contents("saveto/file.giff",$imgData);

适用于 PHP 7.4.13。检查写入权限

,

问题是由于使用Intervention/Image包的resize方法,上传后丢失了动画。

我现在正在使用 imagick 的转换命令来调整动画 GIF 的大小,并且可以正常工作。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...