imageio
imageio copied to clipboard
[Request] Add .APNG/.MNG support?
Any support for Animated PNG or MNG with custom duration for each frame similar to GIF?
Both are currently not supported. Both are based on PNG so they are both feasible. Pure Python png reader/writers exist. Some links:
- Simple pure Python PNG read/write functionality https://github.com/zoofIO/flexx/blob/master/flexx/util/png.py
- APNG support via Pillow https://pypi.python.org/pypi/apng/0.1.0
- Cannot find anything for MNG, but provided its well documented I can imagine that its a matter of extending an existing PNG implementation.
thanks, I'll use apng for now.
Sorry for late reply
https://github.com/zoofIO/flexx/blob/master/flexx/util/png.py
This only support limited format of png (Can only read PNG's that are not interlaced, have a bit depth of 8, and are either RGB or RGBA.)
APNG
This only support python3, but I"m able to convert it to 2.7.x using 3to2 script with some modification. apng.zip
FYI: Another alternative for writing (but not reading) animated PNGs is numpngw
: https://github.com/WarrenWeckesser/numpngw, https://pypi.python.org/pypi/numpngw
As of now, ImageIO can write APNGs, and read single frame from it:
import imageio as iio
import numpy as np
img = iio.v3.imread("imageio:newtonscradle.gif", index=None)
iio.v3.imwrite("test.apng", img)
read_back = iio.v3.imread("test.apng", index=8)
Reading the full stack (index=None
) throws an exception, and I will have to investigate if this is something we are doing or an area where pillow has a bug.
EDIT: Turns out this is a bug in our code and will be fixed by https://github.com/imageio/imageio/pull/750.
Regarding the MNG format, I don't think we support it at present. I tried it, but all plugins I have installed at the moment reject writing mng. I can't test reading, because I don't have a file in that format on hand (donations welcome :) ).
I did find https://github.com/emcconville/wand as a wrapper around imagemagick which claims to support MNG and JNG. Currently, we don't wrap this library so I can't say if that would solve the problem, but it at least provides a direction.