imagemagick - ImageMagick: How to apply one gif's per-frame delays to another gif?
问题描述
I have a workflow where I take gifs from a client, convert them from gif to sprite sheets (png) I can work on, then convert them back to gifs to send back. The Client's frame delays in their gifs are important though, so I need to preserve them.
Is there a way I can grab the frame delays in one gif, and apply them to another gif, using ImageMagick commandline utilities? I'm doing these through a .bat batch file on windows. The gifs have the same dimensions and frame counts.
解决方案
在 Imagemagick 6 中,您可以使用字符串格式 %T 来获取动画延迟。将其放入一个变量中,然后将该变量用于下一个动画的延迟。见https://imagemagick.org/script/escape.php
convert -delay 100 rose: rose: rose: -loop 0 anim.gif
convert anim.gif -format "%T\n" info: | head -n 1
100
请注意,如果没有管道到 head -n 1,Imagemagick 将为每一帧重复一次延迟。
对于 Imagemagick 7,使用 magick 而不是转换。在 Windows .bat 中,将 % 加倍为 %%。
对于 Windows,您可能需要找到与 head -n 1 等效的工具,或者仅解析 %T 的文本输出以从每一帧的所有重复中仅提取一个值。
推荐阅读
- algorithm - 使用 EM 算法填充多个缺失数据
- python - django URL 翻倍
- c++ - 取消定义和重新定义 __cplusplus 宏
- apache-flink - Apache Flink:REST API 检索指标值
- python - Python 迁移:找不到记录器“root”的处理程序
- java - JSONObjectRequest 无法用数据填充对象
- javascript - 如何在表单完成之前禁用 Stripe 付款请求按钮?
- html - 如何在其父 div 中调整 SVG 文件的大小、居中对齐并使其响应?
- php - php如何获取xml标签
- mysql - 如何获取一天收入大于或等于前一天收入的人的详细信息