本次学习将GIF拆分成一张张图片用python实现的过程。
具体实现结果如下:
具体实现代码如下:
import os
from PIL import Image
def analyseImage(path):
'''
Pre-process pass over the image to determine the mode (full or additive).
Necessary as assessing single frames isn't reliable. Need to know the mode
before processing all frames.
预处理通过图像来确定模式(全模式或加法模式)。
必要的,因为评估单个框架是不可靠的。需要知道模式
在处理所有帧之前。
'''
im = Image.open(path)
results = {
'size': im.size,
'mode': 'full',
}
try:
while True:
if im.tile:
tile = im.tile[0]