from PIL import Image import streamlit as st import os # Main function def CREATEGIF(): st.title("Create photoshoot visual") # Set the directory where the uploaded images will be saved UPLOAD_DIR = 'uploaded_images' # Create the directory if it doesn't exist if not os.path.exists(UPLOAD_DIR): os.makedirs(UPLOAD_DIR) # Streamlit app title st.title("Image Upload and Save App") # File uploader allows user to upload an image uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"]) if uploaded_file is not None: # Open the uploaded image image = Image.open(uploaded_file) # Display the uploaded image st.image(image, caption='Uploaded Image.', use_column_width=True) # Save the uploaded image to the specified directory image_path = os.path.join(UPLOAD_DIR, uploaded_file.name) image.save(image_path) st.write(f"Image saved at: {image_path}") else: st.write("No image uploaded yet.") image_files = [f for f in os.listdir("bgImages") if os.path.isfile(os.path.join("bgImages", f))] # Create a dropdown with the list of image files selected_image = st.selectbox("Select an image file", image_files) if selected_image: # Display the selected image image_path = os.path.join("bgImages", selected_image) image = Image.open(image_path) st.image(image, caption=f"Selected image: {selected_image}") if __name__ == "__main__": CREATEGIF()