以不同的速度创建 GIF

Creating GIF with different speed

我创建了一系列图,想以不同的速度制作它们的 GIF。

我知道如何通过以下命令使用 imagemagick 创建 GIF:magick *jpeg -delay 10 name.gif。

但是我希望某些 jpeg 文件显示的时间比其他文件长,我该如何实现?

此外,也许在 python 里面做起来更容易?我有一个数字列表,我想从中创建这个 GIF。

您可以在加载图像之前单独设置延迟:

magick -delay 30 red.png -delay 80 green.png -delay 99 blue.png anim.gif

像这样检查延迟、偏移、配置:

magick identify -format "%f[%s] canvas=%Wx%H size=%wx%h offset=%X%Y %D %Tcentisecs\n"  anim.gif
anim.gif[0] canvas=100x100 size=100x100 offset=+0+0 Undefined 30centisecs
anim.gif[1] canvas=100x100 size=100x100 offset=+0+0 Undefined 80centisecs
anim.gif[2] canvas=100x100 size=100x100 offset=+0+0 Undefined 99centisecs

请注意,由于 -delay 是一个 设置 ,它会保持设置直到更改,因此前 4 帧继承 10 厘秒的延迟,其余帧获得 25 厘秒:

magick -delay 10 frame-[0-3].jpg -delay 25 frame-[4-7].jpg  anim.gif
identify -format "%f[%s] canvas=%Wx%H size=%wx%h offset=%X%Y %D %Tcentisecs\n"  anim.gif
anim.gif[0] canvas=100x100 size=100x100 offset=+0+0 Undefined 10centisecs
anim.gif[1] canvas=100x100 size=100x100 offset=+0+0 Undefined 10centisecs
anim.gif[2] canvas=100x100 size=100x100 offset=+0+0 Undefined 10centisecs
anim.gif[3] canvas=100x100 size=100x100 offset=+0+0 Undefined 10centisecs
anim.gif[4] canvas=100x100 size=100x100 offset=+0+0 Undefined 25centisecs
anim.gif[5] canvas=100x100 size=100x100 offset=+0+0 Undefined 25centisecs
anim.gif[6] canvas=100x100 size=100x100 offset=+0+0 Undefined 25centisecs
anim.gif[7] canvas=100x100 size=100x100 offset=+0+0 Undefined 25centisecs

从那里继续,如果你想做一些更复杂的事情,我会求助于 gifsicle,所以说你想要我上面的东西但是第 4 帧有 17 厘秒的延迟:

# Change delay to 17 on frame 4 only
gifsicle -b anim.gif "#0-3" -d17 "#4" --same-delay "#5-" 

# Check again
anim.gif[0] canvas=100x100 size=100x100 offset=+0+0 Undefined 10centisecs
anim.gif[1] canvas=100x100 size=100x100 offset=+0+0 Undefined 10centisecs
anim.gif[2] canvas=100x100 size=100x100 offset=+0+0 Undefined 10centisecs
anim.gif[3] canvas=100x100 size=100x100 offset=+0+0 Undefined 10centisecs
anim.gif[4] canvas=100x100 size=100x100 offset=+0+0 Undefined 17centisecs    <--- HERE
anim.gif[5] canvas=100x100 size=100x100 offset=+0+0 Undefined 25centisecs
anim.gif[6] canvas=100x100 size=100x100 offset=+0+0 Undefined 25centisecs
anim.gif[7] canvas=100x100 size=100x100 offset=+0+0 Undefined 25centisecs

关键字:ImageMagick、gifsicle、延迟、单独设置延迟、单个帧、厘秒。