
image.png
from PIL import Image
import glob
def create_faster_gif(new_duration=200): # 默认200毫秒,比原来的500ms快
# 读取所有帧
frames = [Image.open(f) for f in sorted(glob.glob("*.png"))]
# 保存为更快的GIF
frames[0].save(
"fast_output.gif",
format="GIF",
append_images=frames[1:],
save_all=True,
duration=new_duration, # 减小这个值来加快速度
loop=0
)
print(f"快速GIF已生成,每帧时长:{new_duration}毫秒")
# 使用示例
create_faster_gif(20)

fast_output.gif