PyPNG, the most widely used PNG library for Python, doesn't seem to support animated PNGs. There's a library for writing animated PNGs, but I can't find an equivalent one for reading them. Anyone know a way of getting the frames out of this little supported image format?
Asked
Active
Viewed 1,986 times
2
-
2Well, asking for a library that does would be off topic. However, even if there is such a library, one thing you can do yourself is look into the source code of the [`write_apng()`](https://github.com/WarrenWeckesser/numpngw/blob/master/numpngw.py#L969) encoder and just write your own decoder based on that. – Reti43 Mar 31 '16 at 01:34
2 Answers
3
There's a library for APNGs now - https://github.com/eight04/pyAPNG
> pip install apng
Extract frames from APNG file:
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
It also supports creating APNGs.

Brian Burns
- 20,575
- 8
- 83
- 77
2
Ultimately, I found it was easiest just to invoke APNG Disassembler via command line, then open the disassembled frames. Hope this helps someone!

Tom Quinn
- 614
- 4
- 17