使用ImageSequence, 把gif中图片帧序列化成为可迭代对象。
from PIL import ImageSequence
image_name = 'gif'
for i, frame in enumerate(ImageSequence.Iterator(img)):
frame.save(f'{image_name}_{i}.png', frame)
from PIL import ImageSequence
image_name = 'gif'
for i, frame in enumerate(ImageSequence.Iterator(img)):
frame.save(f'{image_name}_{i}.png', frame)