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**")