30+ FPS GIF
See original GitHub issueI can’t seem to figure out how to read/write 30+ FP GIF’s with the “GIF-FI” format.
If I do:
imageio.mimwrite("test.gif", images, format="GIF-FI", fps=29)
Followed by:
frame_duration_ms = imageio.get_reader("test.gif", format="GIF-FI").get_next_data().meta.ANIMATION.FrameTime
Then frame_duration_ms
is 30
, but I expect it to be 34
(1000 / 29 == 34.4).
I’ve done some data collection, and writing/reading generally comes out correct…sometimes:
- write 1 / read 1
- write 10 / read 10
- write 15 / read 16.666666
- write 25 / read 25
- write 30 / read 33.333333
- write 40 / read 50
- write 50 / read 50
- write 60 / read 100
- write 100 / read 100
The in -> out is an odd pattern… it seems like there’s an inappropriate truncation/division happening somewhere?
I’ve poked around the codebase a bit, and as far as imageio/plugins/_freeimage.py(759)set_meta_data()
, the frametime is correct:
> /Users/joe/repos/third-party/imageio/imageio/plugins/_freeimage.py(759)set_meta_data()
758 # Set properties
--> 759 import ipdb; ipdb.set_trace() # XXX BREAKPOINT
760 lib.FreeImage_SetTagKey(tag, tag_name.encode('utf-8'))
ipdb> tag_name
'FrameTime'
ipdb> tag_val
array([34], dtype=uint32)
ipdb>
At the point the bytes are read from lib.FreeImage, the value is already wrong:
> /Users/joe/repos/third-party/imageio/imageio/plugins/_freeimage.py(692)get_meta_data()
691 import ipdb; ipdb.set_trace() # XXX BREAKPOINT
--> 692 subdict = metadata.setdefault(model_name, Dict())
693 subdict[tag_name] = tag_val
ipdb> tag_val
30
ipdb>
Am I doing something wrong, or is there a bug in the GIF reading/writing code?
Using:
- imageio:
v0.5.1-658-g5d323c0
from this repo - FreeImage:
3.17.0
from brew - OS:
OSX 10.11.6
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
also, this module is sweet - thank you for building it and making it available!
Hehe, after looking into what’s wrong with both the Pillow and FI animated gif modules, I found that its a limitation of GIF itself; the “delay time”, in GIF’s terminology is expressed in hundredths of seconds. See e.g. https://en.wikipedia.org/wiki/GIF (search for “delay”), or https://github.com/imageio/imageio/blob/master/imageio/plugins/pillowmulti.py#L288.
I will add a note to the docs 😃