Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from PIL import Image, ImageEnhance, ImageOps | |
| import io | |
| # Title of the app | |
| st.title("🖼️ Image Editor App") | |
| # Sidebar for options | |
| st.sidebar.header("Image Editor Options") | |
| # Upload image | |
| uploaded_image = st.sidebar.file_uploader("Upload an Image", type=["jpg", "jpeg", "png"]) | |
| if uploaded_image: | |
| # Open the uploaded image | |
| image = Image.open(uploaded_image) | |
| st.image(image, caption="Uploaded Image", use_column_width=True) | |
| # Image editing options | |
| st.sidebar.subheader("Filters") | |
| # Grayscale | |
| if st.sidebar.checkbox("Apply Grayscale"): | |
| image = ImageOps.grayscale(image) | |
| # Brightness | |
| brightness = st.sidebar.slider("Adjust Brightness", 0.5, 2.0, 1.0, 0.1) | |
| enhancer = ImageEnhance.Brightness(image) | |
| image = enhancer.enhance(brightness) | |
| # Show edited image | |
| st.subheader("Edited Image") | |
| st.image(image, caption="Edited Image", use_column_width=True) | |
| # Download edited image | |
| buf = io.BytesIO() | |
| image.save(buf, format="PNG") | |
| byte_im = buf.getvalue() | |
| st.download_button(label="Download Edited Image", | |
| data=byte_im, | |
| file_name="edited_image.png", | |
| mime="image/png") | |
| else: | |
| st.info("Please upload an image to get started.") | |
| # Footer | |
| st.markdown("---") | |
| st.caption("Developed with ❤️ using Streamlit and deployed on Hugging Face Spaces.") | |