Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from PIL import Image, ImageEnhance, ImageOps
|
| 3 |
+
import io
|
| 4 |
+
|
| 5 |
+
# Title of the app
|
| 6 |
+
st.title("🖼️ Image Editor App")
|
| 7 |
+
|
| 8 |
+
# Sidebar for options
|
| 9 |
+
st.sidebar.header("Image Editor Options")
|
| 10 |
+
|
| 11 |
+
# Upload image
|
| 12 |
+
uploaded_image = st.sidebar.file_uploader("Upload an Image", type=["jpg", "jpeg", "png"])
|
| 13 |
+
|
| 14 |
+
if uploaded_image:
|
| 15 |
+
# Open the uploaded image
|
| 16 |
+
image = Image.open(uploaded_image)
|
| 17 |
+
st.image(image, caption="Uploaded Image", use_column_width=True)
|
| 18 |
+
|
| 19 |
+
# Image editing options
|
| 20 |
+
st.sidebar.subheader("Filters")
|
| 21 |
+
|
| 22 |
+
# Grayscale
|
| 23 |
+
if st.sidebar.checkbox("Apply Grayscale"):
|
| 24 |
+
image = ImageOps.grayscale(image)
|
| 25 |
+
|
| 26 |
+
# Brightness
|
| 27 |
+
brightness = st.sidebar.slider("Adjust Brightness", 0.5, 2.0, 1.0, 0.1)
|
| 28 |
+
enhancer = ImageEnhance.Brightness(image)
|
| 29 |
+
image = enhancer.enhance(brightness)
|
| 30 |
+
|
| 31 |
+
# Show edited image
|
| 32 |
+
st.subheader("Edited Image")
|
| 33 |
+
st.image(image, caption="Edited Image", use_column_width=True)
|
| 34 |
+
|
| 35 |
+
# Download edited image
|
| 36 |
+
buf = io.BytesIO()
|
| 37 |
+
image.save(buf, format="PNG")
|
| 38 |
+
byte_im = buf.getvalue()
|
| 39 |
+
st.download_button(label="Download Edited Image",
|
| 40 |
+
data=byte_im,
|
| 41 |
+
file_name="edited_image.png",
|
| 42 |
+
mime="image/png")
|
| 43 |
+
else:
|
| 44 |
+
st.info("Please upload an image to get started.")
|
| 45 |
+
|
| 46 |
+
# Footer
|
| 47 |
+
st.markdown("---")
|
| 48 |
+
st.caption("Developed with ❤️ using Streamlit and deployed on Hugging Face Spaces.")
|