Python实现GIF动画转置 超好玩!

作者: 我叫钱小钱 | 来源:发表于2017-05-01 22:17 被阅读334次

    偶尔搜索图片的时候发现Python GIF转置就随便找了两张玩玩

    from PIL import Image, ImageSequence
    
    with Image.open('pic.gif') as im:
        if im.is_animated:
            frames = [f.copy() for f in ImageSequence.Iterator(im)]
            frames.reverse() # 内置列表倒序方法
            # 将倒序后的所有帧图像保存下来
            frames[0].save('pic_reverse.gif', save_all=True, append_images=frames[1:])
    
    # 鬼畜打乱GIF动画效果
    # import random
    # random.shuffle(frames)
    

    代码有些失帧,如果有专业朋友也请告知如何避免失贞的方法。

    positive sequence_1.gif positive sequence_2.gif reverse_1.gif reverse_2.gif

    相关文章

      网友评论

      本文标题:Python实现GIF动画转置 超好玩!

      本文链接:https://www.haomeiwen.com/subject/jbpqtxtx.html