
偶尔搜索图片的时候发现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)
代码有些失帧,如果有专业朋友也请告知如何避免失贞的方法。




网友评论