LoginSignup
1
3

More than 3 years have passed since last update.

フォルダ内の画像を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指定できます。

test.gif

サンプル画像に意味はありません。

🐣


フリーランスエンジニアです。
お仕事のご相談こちらまで
rockyshikoku@gmail.com

Core MLを使ったアプリを作っています。
機械学習関連の情報を発信しています。

Twitter
Medium

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3