首页 > 解决方案 > 如何在不改变速度的情况下改变 gif 的延迟

问题描述

出于愚蠢的时间原因,我需要一个延迟为 6 的 gif。唉,我的材料是延迟 20。

我实际上需要的是将延迟降低到 6,同时将每帧乘以三到四次。我不介意时间有点不对。

这似乎是一个足够简单的问题,但完全无法解决。

标签: imagemagickimagemagick-convert

解决方案


你可以这样做:

#!/bin/bash

# Split animation into constituent frames, saving as "frame-nnn.gif"
convert animated.gif -coalesce frame-%03d.gif

# Make array of all framenames
frames=( frame-*gif )

# Triplicate array elements
for ((i=0;i<${#frames[@]};i++)); do newframes+="${frames[i]} ${frames[i]} ${frames[i]} "; done

# DEBUG echo ${newframes[@]}

# Rebuild animation with new speed
convert -delay 10 ${newframes[@]} new.gif

# Clean up
rm frame-*.gif 2> /dev/null

我的脚本假定您的原件被调用animated.gif,结果将被调用new.gif。显然,您可以根据需要更改延迟和重复次数,我选择的值是说明性的。


推荐阅读