Skip to main content
 首页 » 编程设计

python之在 Python 中读取动画 PNG

2024年10月24日9shangdawei

PyPNG ,最广泛使用的 Python PNG 库,似乎不支持动画 PNG。有一个图书馆 writing animated PNGs , 但我找不到与之相当的阅读它们。任何人都知道从这种受支持的图像格式中获取帧的方法吗?

请您参考如下方法:

现在有一个 APNG 库 - https://github.com/eight04/pyAPNG

> pip install apng 

从 APNG 文件中提取帧:

from apng import APNG 
 
im = APNG.open("animation.png") 
i = 0 
for png, control in im.frames: 
    png.save("{i}.png".format(i=i)) 
    i += 1 

它还支持创建 APNG。