Create Animated Images Using Python

No Photoshop? Not a problem! Learn how to easily create animated images from a list of static images or a video in Python.

Yong Cui
Published in
7 min readJan 23, 2020



Animated images are a series of static images that are automatically played to show related content in a continuous and dynamic fashion, with the advantage of having a smaller size than videos. In addition, many web and mobile applications support animated images just like regular static images, and they don’t always allow you to upload videos. In this case, animated images can be very useful. Certainly, there are many other reasons why animated images are preferred. Sometimes, it’s just pure fun to put related or unrelated images together.

There are some online websites, desktop software, and command-line tools that can be used to create animated images. However, they’re not “pythonic” by the standard. Since many of us have been using Python more or less for various purposes, we have developed familiarity with the syntax and usage of certain built-in and third-party libraries. I thought it would be handy if we know how to create animated images using Python. Thus, in this article, I would like to share with you the steps to make animated images in Python, with the assumption that you have adequate experience working with Python.


We’ll use the imageio library to create animated images. This library provides various functions that allow us to read and write a wide range of image data, including animated images. We’ll also need to install another related library called imageio-ffmpeg to provide functionalities for processing videos. Finally, we’ll install the pygifsicle library that can be used to reduce the size of the animated images. These libraries can be conveniently installed using pip.

pip install imageio
pip install imageio-ffmpeg
pip install pygifsicle

The current article will have two parts.

  • The first will cover the steps to generate an animated image from a set of individual images as well as from a video.
  • The second will show you how we can optimize the animated image by reducing its size to a more manageable level.



Yong Cui
The Startup

Work at the nexus of biomedicine, data science & mobile dev. Author of Python How-to by Manning (