Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from PIL import Image, ImageEnhance
|
| 3 |
+
|
| 4 |
+
# Title of the app
|
| 5 |
+
st.title("Simple Image Editor")
|
| 6 |
+
|
| 7 |
+
# Upload image
|
| 8 |
+
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
| 9 |
+
|
| 10 |
+
if uploaded_file is not None:
|
| 11 |
+
# Open the image file
|
| 12 |
+
image = Image.open(uploaded_file)
|
| 13 |
+
|
| 14 |
+
# Display the original image
|
| 15 |
+
st.image(image, caption='Original Image', use_column_width=True)
|
| 16 |
+
|
| 17 |
+
# Apply filters
|
| 18 |
+
filter_option = st.selectbox("Choose a filter", ["None", "Grayscale", "Brightness"])
|
| 19 |
+
|
| 20 |
+
if filter_option == "Grayscale":
|
| 21 |
+
image = image.convert("L")
|
| 22 |
+
elif filter_option == "Brightness":
|
| 23 |
+
enhancer = ImageEnhance.Brightness(image)
|
| 24 |
+
factor = st.slider("Adjust brightness", 0.1, 3.0, 1.0)
|
| 25 |
+
image = enhancer.enhance(factor)
|
| 26 |
+
|
| 27 |
+
# Display the edited image
|
| 28 |
+
st.image(image, caption='Edited Image', use_column_width=True)
|
| 29 |
+
|
| 30 |
+
# Download the edited image
|
| 31 |
+
st.download_button(
|
| 32 |
+
label="Download Image",
|
| 33 |
+
data=image.tobytes(),
|
| 34 |
+
file_name="edited_image.png",
|
| 35 |
+
mime="image/png"
|
| 36 |
+
)
|