create an app to turn images to gif
To upload files, please first save the app
import streamlit as st
from PIL import Image
import io
st.title("Image to GIF Converter")
uploaded_files = st.file_uploader("Upload Images", type=['jpg', 'jpeg', 'png'], accept_multiple_files=True)
if uploaded_files:
images = []
for uploaded_file in uploaded_files:
img = Image.open(uploaded_file)
images.append(img)
if st.button("Convert to GIF"):
gif_path = "output.gif"
images[0].save(gif_path, save_all=True, append_images=images[1:], optimize=False, duration=500, loop=0)
with open(gif_path, "rb") as f:
st.download_button(label="Download GIF", data=f, file_name=gif_path)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?