【问题标题】:How to create a gif animation that plays only once如何创建只播放一次的 gif 动画
【发布时间】:2016-06-30 05:30:17
【问题描述】:

我正在尝试生成只播放帧一次的动画 gif。

当我将 LoopCount 设置为 1 时,它会播放帧两次。当我将 LoopCount 设置为 0 或 -1 时,它会无限循环。

img := image.(*image.Paletted)

outGif := &gif.GIF{}
outGif.LoopCount = 0
outGif.Image = append(outGif.Image, img)
outGif.Delay = append(outGif.Delay, 10)

f, err := os.Create("/tmp/test.gif")
if err != nil {
    panic(err)
}
defer f.Close()

gif.EncodeAll(f, outGif)

如何确保它只播放帧一次?

【问题讨论】:

  • 当我尝试这个 0 永远循环时,12 完全按预期工作,1 只播放一次动画?
  • 嗯...你用什么来播放gif?我用铬。也许那是播放两次。

标签: go gif animated-gif


【解决方案1】:

浏览器对循环计数器的解释不同。对于单循环 gif,Chrome 循环两次,而 Firefox 只播放一次动画。

参见本期GifCreator - Unable to create non loop GIF image

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-15
    • 1970-01-01
    相关资源
    最近更新 更多