Gifを一枚づつに分解すると、2枚目以降は差分しか保存されていないので、
「なら合成してしまおう」とpython3で合成するプログラムを書いてみました。
gif画像の分解にONOさんのブログのコード(opencv版)を使いました。
gif_combine.py
import os
import cv2
img0 = cv2.imread("screen_caps\\0.png",-1)
print(img.shape)
size = img.shape[:2]
#透過箇所(緑)か
def isGreen(color):
if color[0]==0 and color[1]==255 and color[2]==0 and color[3]==255:
return True
return False
if not os.path.exists("Combine"):
os.mkdir("combine")
for i in range(308):
img = cv2.imread("screen_caps\\"+str(i)+".png",-1)
for x in range(size[0]):
for y in range(size[1]):
mask = img[x,y,:]
if not isGreen(mask):
img0[x,y,:] = mask
print("save num:"+str(i))
print(cv2.imwrite("combine\\gif"+str(i)+".png",img0))
約500*400のサイズでもそれなりに時間がかかったので、最適化のご指南いただけると幸いです。