Python Create GIF with Images Using ImageIO: A Complete Guide – Python Tutorial

By | October 25, 2019

Python can create a gif with some images using moviepy, here is an tutorial.

Python Create GIF with Images Using MoviePy: A Complete Guide – Python Tutorial

However, we can find moviepy use imageio library to create a gif. How to create a gif with images using imageio? In this tutorial, we will tell you how to do.

Import library

import imageio

Define a gif file

giffile = 'demo2.gif'

In this example, we will save images to a gif file demo2.gif.

Load images

images_data = []
#load 10 images
for i in range(10):
    data = imageio.imread('E:\\video-images\\'+str(i+1)+'.jpg')
    images_data.append(data)

Here we will use imageio.imread() to read image data to a list. In this tutorial, we will read 10 jpg images.

Create gif with images

imageio.mimwrite(giffile, images_data, format= '.gif', fps = 1)

We can use imageio.mimwrite() function to create a gif image with some images. To understand how to use imageio.mimwrite(), you can refer to this tutorial.

Understand imageio.mimwrite() with Examples for Beginners- ImageIO Tutorial

This is a gif preview.

imageio.mimwrite() create a gif with images

Leave a Reply