Untitled

 avatar
unknown
plain_text
a month ago
766 B
4
Indexable
import imageio.v2 as imageio

# List of image file paths to include in the GIF
image_paths = [
    'image1.png',  # Replace with your image file paths
    'image2.png',
    'image3.png'
]

# Output path for the GIF
output_path = 'output.gif'

# Create the GIF
def create_gif(image_paths, output_path, duration=0.5):
    """
    Create a GIF from a list of images.

    :param image_paths: List of file paths to images.
    :param output_path: Path to save the output GIF.
    :param duration: Duration of each frame in seconds.
    """
    images = [imageio.imread(image_path) for image_path in image_paths]
    imageio.mimsave(output_path, images, duration=duration)
    print(f"GIF saved at {output_path}")

# Call the function
create_gif(image_paths, output_path)
Leave a Comment