偶爾搜索圖片的時(shí)候發(fā)現(xiàn)Python GIF轉(zhuǎn)置就隨便找了兩張玩玩
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() # 內(nèi)置列表倒序方法
# 將倒序后的所有幀圖像保存下來
frames[0].save('pic_reverse.gif', save_all=True, append_images=frames[1:])
# 鬼畜打亂GIF動(dòng)畫效果
# import random
# random.shuffle(frames)
代碼有些失幀,如果有專業(yè)朋友也請(qǐng)告知如何避免失貞的方法。
positive sequence_1.gif
positive sequence_2.gif
reverse_1.gif
reverse_2.gif