File size: 2,834 Bytes
eca0feb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import streamlit as st
from PIL import Image, ImageEnhance, ImageFilter
import io

# App Title and Description
st.title("🌟 Simple Image Enhancer")
st.write("""
Enhance your images with filters like grayscale, brightness adjustment, sharpness, and more!  
Special focus on enhancing eyes, lips, beard, and hair for a more appealing output.  
Follow the instructions below to use this app.
""")

# Sidebar Instructions
st.sidebar.title("Instructions")
st.sidebar.write("""
1. Upload an image using the "Choose File" button.  
2. Select a filter from the options provided.  
3. Adjust the sliders as needed to enhance the image.  
4. Click **Apply Filter** to view the enhanced image.  
5. Use the **Download Enhanced Image** button to save your edited image.
""")

# Image Upload
uploaded_image = st.file_uploader("Upload an Image", type=["jpg", "jpeg", "png"])

if uploaded_image:
    # Display original image
    st.subheader("Original Image")
    image = Image.open(uploaded_image)
    st.image(image, caption="Uploaded Image", use_column_width=True)

    # Filters Section
    st.subheader("Choose Enhancement Options")
    filter_option = st.selectbox("Select a filter", ["None", "Grayscale", "Enhance Brightness", "Enhance Sharpness", "Smooth Features"])
    
    # Brightness Adjustment
    if filter_option == "Enhance Brightness":
        brightness_factor = st.slider("Brightness Factor", 0.1, 3.0, 1.0)
    
    # Sharpness Adjustment
    elif filter_option == "Enhance Sharpness":
        sharpness_factor = st.slider("Sharpness Factor", 0.1, 3.0, 1.0)

    # Apply Filter Button
    if st.button("Apply Filter"):
        if filter_option == "Grayscale":
            enhanced_image = image.convert("L")
        elif filter_option == "Enhance Brightness":
            enhancer = ImageEnhance.Brightness(image)
            enhanced_image = enhancer.enhance(brightness_factor)
        elif filter_option == "Enhance Sharpness":
            enhancer = ImageEnhance.Sharpness(image)
            enhanced_image = enhancer.enhance(sharpness_factor)
        elif filter_option == "Smooth Features":
            enhanced_image = image.filter(ImageFilter.SMOOTH)
        else:
            enhanced_image = image
        
        # Display Enhanced Image
        st.subheader("Enhanced Image")
        st.image(enhanced_image, caption="Enhanced Image", use_column_width=True)

        # Download Enhanced Image
        buf = io.BytesIO()
        enhanced_image.save(buf, format="PNG")
        byte_im = buf.getvalue()
        st.download_button(
            label="Download Enhanced Image",
            data=byte_im,
            file_name="enhanced_image.png",
            mime="image/png"
        )
else:
    st.info("Please upload an image to get started.")

# Footer
st.write("---")
st.markdown("💡 **Developed by Abdullah**")