在 Python 中读取动画 PNG?
Reading animated PNGs in Python?
PyPNG, the most widely used PNG library for Python, doesn't seem to support animated PNGs. There's a library for writing animated PNGs,但我找不到对应的阅读它们。任何人都知道从这种受支持的图像格式中获取帧的方法吗?
最终,我发现最简单的方法是通过命令行调用 APNG Disassembler,然后打开反汇编的框架。希望这对某人有所帮助!
现在有一个 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。
PyPNG, the most widely used PNG library for Python, doesn't seem to support animated PNGs. There's a library for writing animated PNGs,但我找不到对应的阅读它们。任何人都知道从这种受支持的图像格式中获取帧的方法吗?
最终,我发现最简单的方法是通过命令行调用 APNG Disassembler,然后打开反汇编的框架。希望这对某人有所帮助!
现在有一个 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。