Spaces:
Sleeping
Update App. Py
Browse filesimport streamlit as st
from PIL import Image, ImageOps
# Function to apply effects
def apply_effect(image, effect):
if effect == "kiss":
image = image.convert("L") # Convert to grayscale
elif effect == "sepia":
sepia_img = ImageOps.colorize(image.convert("L"), black="black", white="orange")
image = sepia_img
elif effect == "invert":
image = ImageOps.invert(image.convert("RGB"))
return image
# Streamlit app
st.title("Image Effect Converter")
# Upload image
uploaded_file = st.file_uploader("Upload an image", type=["jpg", "png", "jpeg"])
if uploaded_file is not None:
# Display the uploaded image
image = Image.open(uploaded_file)
st.image(image, caption="Uploaded Image", use_column_width=True)
# Select an effect
effect = st.selectbox("Choose an effect", ["kiss", "sepia", "invert"])
# Apply effect
if st.button("Apply Effect"):
processed_image = apply_effect(image, effect)
st.image(processed_image, caption="Processed Image", use_column_width=True)
# Download button
processed_image.save("processed_image.png")
with open("processed_image.png", "rb") as file:
st.download_button(
label="Download Image",
data=file,
file_name="processed_image.png",
mime="image/png"
)
|
@@ -1,42 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
from PIL import Image, ImageOps
|
| 3 |
-
|
| 4 |
-
# Function to apply effects
|
| 5 |
-
def apply_effect(image, effect):
|
| 6 |
-
if effect == "kiss":
|
| 7 |
-
image = image.convert("L") # Convert to grayscale
|
| 8 |
-
elif effect == "sepia":
|
| 9 |
-
sepia_img = ImageOps.colorize(image.convert("L"), black="black", white="orange")
|
| 10 |
-
image = sepia_img
|
| 11 |
-
elif effect == "invert":
|
| 12 |
-
image = ImageOps.invert(image.convert("RGB"))
|
| 13 |
-
return image
|
| 14 |
-
|
| 15 |
-
# Streamlit app
|
| 16 |
-
st.title("Image Effect Converter")
|
| 17 |
-
|
| 18 |
-
# Upload image
|
| 19 |
-
uploaded_file = st.file_uploader("Upload an image", type=["jpg", "png", "jpeg"])
|
| 20 |
-
|
| 21 |
-
if uploaded_file is not None:
|
| 22 |
-
# Display the uploaded image
|
| 23 |
-
image = Image.open(uploaded_file)
|
| 24 |
-
st.image(image, caption="Uploaded Image", use_column_width=True)
|
| 25 |
-
|
| 26 |
-
# Select an effect
|
| 27 |
-
effect = st.selectbox("Choose an effect", ["kiss", "sepia", "invert"])
|
| 28 |
-
|
| 29 |
-
# Apply effect
|
| 30 |
-
if st.button("Apply Effect"):
|
| 31 |
-
processed_image = apply_effect(image, effect)
|
| 32 |
-
st.image(processed_image, caption="Processed Image", use_column_width=True)
|
| 33 |
-
|
| 34 |
-
# Download button
|
| 35 |
-
processed_image.save("processed_image.png")
|
| 36 |
-
with open("processed_image.png", "rb") as file:
|
| 37 |
-
st.download_button(
|
| 38 |
-
label="Download Image",
|
| 39 |
-
data=file,
|
| 40 |
-
file_name="processed_image.png",
|
| 41 |
-
mime="image/png"
|
| 42 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|