File size: 1,384 Bytes
c733130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import 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"
            )