フォルダ内の画像をgifに。ちょうかんたんなやーつ。
画像を書き込む順番は frame0.png, frame1.png...などと書き込みたい順番にファイル名をつけておくとよろしい。
import imageio
import glob
imageio.plugins.freeimage.download()
anim_file = 'test.gif' #書き込み先
filenames = glob.glob("/image_dir" + '/frame*.png') #フォルダ内の画像を取得
filenames = sorted(filenames) #名前で並べ替え
last = -1
images = []
for filename in filenames:
image = imageio.imread(filename)
images.append(image)
imageio.mimsave(anim_file, images, 'GIF-FI', fps=5) # fps指定できます。
サンプル画像に意味はありません。
🐣
フリーランスエンジニアです。
お仕事のご相談こちらまで
rockyshikoku@gmail.com
Core MLを使ったアプリを作っています。
機械学習関連の情報を発信しています。