Spaces:
Sleeping
Sleeping
File size: 1,443 Bytes
8412a7c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
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.")
|