Skip to content

Latest commit

 

History

History
61 lines (39 loc) · 1008 Bytes

File metadata and controls

61 lines (39 loc) · 1008 Bytes

Image to GIF Converter

This Python script combines multiple PNG images into an animated GIF using the imageio library.

Requirements

Install the required package:

pip install imageio

Files

Place your images in the same directory as the script:

image1.png
image2.png

Code

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)

How It Works

  1. Loads each image from the filenames list.
  2. Stores the images in a Python list.
  3. Creates an animated GIF named image.gif.

Parameters

  • duration=500 → Displays each frame for 500 milliseconds.
  • loop=0 → Loops infinitely.

Run

python main.py

After execution, an image.gif file will be created in the current directory.

Example Output

image.gif

An animated GIF generated from image1.png and image2.png.