This Python script combines multiple PNG images into an animated GIF using the imageio library.
Install the required package:
pip install imageioPlace your images in the same directory as the script:
image1.png
image2.png
import imageio.v3 as iio
filenames = ['image1.png', 'image2.png']
images = []
for filename in filenames:
images.append(iio.imread(filename))
iio.imwrite('image.gif', images, duration=500, loop=0)- Loads each image from the
filenameslist. - Stores the images in a Python list.
- Creates an animated GIF named
image.gif.
duration=500→ Displays each frame for 500 milliseconds.loop=0→ Loops infinitely.
python main.pyAfter execution, an image.gif file will be created in the current directory.
image.gif
An animated GIF generated from image1.png and image2.png.