Using https://github.com/python-pillow/Pillow/blob/main/Tests/images/apng/different_durations.png
from PIL import Image, ImageSequence
ddp = Image.open('different_durations.png')
print([frame.info.get('duration') for frame in ImageSequence.Iterator(ddp)]) # [4000.0, 1000.0]
ddp.save('different_durations.gif',save_all=True)
ddg = Image.open('different_durations.gif')
print([frame.info.get('duration') for frame in ImageSequence.Iterator(ddg)]) # [4000, 1000]
ddg.save('same_durations.png',save_all=True)
sdp = Image.open('same_durations.png')
print([frame.info.get('duration') for frame in ImageSequence.Iterator(sdp)]) # [1000.0, 1000.0]
Also, ImageMagick (version 7.1.1-33) says the duration of the second frame is actually 990, not 1000.
> magick identify -format %T\n apng:different_durations.png
400
99
I'm not sure what's going on there though, because the duration parsing isn't complicated.
|
delay_num, delay_den = i16(s, 20), i16(s, 22) |
|
if delay_den == 0: |
|
delay_den = 100 |
|
self.im_info["duration"] = float(delay_num) / float(delay_den) * 1000 |
Using https://github.com/python-pillow/Pillow/blob/main/Tests/images/apng/different_durations.png
Also, ImageMagick (version 7.1.1-33) says the duration of the second frame is actually 990, not 1000.
I'm not sure what's going on there though, because the duration parsing isn't complicated.
Pillow/src/PIL/PngImagePlugin.py
Lines 669 to 672 in 219add0