python将gif图片转换成png图片

转自:https://blog.csdn.net/huxiangen/article/details/80825181 

#将gif图片转成PNG图片
im = Image.open('image.gif')
def iter_frames(im):
    try:
        i= 0
        while 1:
            im.seek(i)
            imframe = im.copy()
            if i == 0:
                palette = imframe.getpalette()
            else:
                imframe.putpalette(palette)
            yield imframe
            i += 1
    except EOFError:
        pass
for i, frame in enumerate(iter_frames(im)):
    frame.save('image.png',**frame.info)

 

 

    原文作者:tech_for_future
    原文地址: https://blog.csdn.net/qq_28388339/article/details/106859481
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞