Skip to content

Commit a598d8e

Browse files
GIF creator Added
1 parent c84e81c commit a598d8e

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

GIF/README.md

Whitespace-only changes.

GIF/gifnew.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from PIL import Image
2+
import glob
3+
4+
def convert_to_gif(image_folder, gif_name, duration):
5+
images = glob.glob(image_folder + "/*.jpg") # Change the file extension if necessary
6+
7+
frames = []
8+
for image in images:
9+
with Image.open(image) as img:
10+
frames.append(img.convert("RGBA"))
11+
12+
frames[0].save(gif_name, format="GIF", append_images=frames[1:], save_all=True, duration=duration, loop=0)
13+
print("GIF created successfully!")
14+
15+
def main():
16+
image_folder = "Image-Slideshow" # Path to the folder containing the images
17+
gif_name = "output.gif" # Name of the output GIF file
18+
duration = 500 # Duration between frames in milliseconds
19+
20+
convert_to_gif(image_folder, gif_name, duration)
21+
22+
if __name__ == "__main__":
23+
main()

0 commit comments

Comments
 (0)