I am creating GIFs with the pillow imaging library. I'm running into an issue where I am trying to make certain frames flicker very fast with the minimum frame duration possible, but when I set the frame to have a duration of 1 (the lowest possible duration, out of 100 for a GIF), it actually seems to last for longer than expected.
I save the gif with a simple Image.save() (GIF format) command similar to the following:
# durations are actually in milliseconds in the pillow library, but
# they translate to 100ths of a second (1/10 of the value input here)
durations = [650, 10, 900, 750, 10, 800, 10, ... ]
my_gif.save(filename, format='GIF', save_all=True, duration=durations, loop=0, disposal=2)
I am not sure if this issue is specific to the pillow library or just to the GIF format more generally. But I have noticed the following things:
- The gif appears visually slower than expected
- When I load my generated GIF into a GIF editing tool, such as EZGif.com, it reports that the frame durations are as expected - the "flicker frames" have a duration of 1, which is the frame duration I used when saving the file.
- When I speed up the GIF using EZGif, weirdly, the "sped up" version of the GIF that is generated by EZGif uses a frame duration of 2 instead of 1 for the flicker frames, but it appears to play faster visually, much closer to what I actually want to happen.
Original Image "Sped Up" Image

Reported duration of each frame when loaded into EZGif
Original Image | Sped Up Image
65 32
1 2
90 45
1 2
75 37
1 2
80 40
1 2
4 2
1 2
114 56
1 2
35 17
1 2
100 50
1 2
1 2
1 2
20 10
1 2
250 125
1 2
The question...
Can someone help explain the reason for this seeming disparity? Is this how the GIF format works, or is it a problem with the pillow imaging library? How can I generate GIFs that have a faster "flickering" effect as I would prefer them to?