21
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Python PillowでPNGからGIFを作る

Posted at
  • 同ディレクトリ内にあるPNGからGIFを生成する
  • Python 3.6.5

ディレクトリ構成

gif-test
  ├── main.py
  ├── requirements.txt
  ├── 001.png
  ├── 002.png
  └── 003.png

ファイルの内容

  • requirements.txt

    requirements.txt
    Pillow==5.2.0
    
  • main.py

    main.py
    from PIL import Image
    import glob
    
    files = sorted(glob.glob('./*.png'))
    images = list(map(lambda file: Image.open(file), files))
    
    images[0].save('out.gif', save_all=True, append_images=images[1:], duration=400, loop=0)
    
  • *.png

    • 適当なファイルを

参考

21
13
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
21
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?