an app that allows to upload images to it from my local machine
To upload files, please first save the app
import streamlit as st
from PIL import Image
import io
st.title("Image Uploader")
st.write("Upload your images using the file uploader below.")
uploaded_files = st.file_uploader(
"Choose image files",
type=['png', 'jpg', 'jpeg', 'gif', 'bmp'],
accept_multiple_files=True
)
if uploaded_files:
for uploaded_file in uploaded_files:
# Open the image using PIL
image = Image.open(uploaded_file)
# Create two columns for each image
col1, col2 = st.columns(2)
with col1:
st.write("Image details:")
st.write(f"Filename: {uploaded_file.name}")
st.write(f"Size: {uploaded_file.size} bytes")
st.write(f"Image dimensions: {image.size}")
st.write(f"Image format: {image.format}")
with col2:
# Display the image
st.image(
image,
caption=uploaded_file.name,
use_column_width=True
)
st.divider() # Add a visual separator between images
else:
st.info("Please upload some images to see them displayed here.")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?