Image-Enhancer / app.py
WasifAKhan's picture
Create app.py
a393ce0 verified
import streamlit as st
from PIL import Image, ImageEnhance
# Title of the app
st.title("Simple Image Editor")
# Upload image
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
if uploaded_file is not None:
# Open the image file
image = Image.open(uploaded_file)
# Display the original image
st.image(image, caption='Original Image', use_column_width=True)
# Apply filters
filter_option = st.selectbox("Choose a filter", ["None", "Grayscale", "Brightness"])
if filter_option == "Grayscale":
image = image.convert("L")
elif filter_option == "Brightness":
enhancer = ImageEnhance.Brightness(image)
factor = st.slider("Adjust brightness", 0.1, 3.0, 1.0)
image = enhancer.enhance(factor)
# Display the edited image
st.image(image, caption='Edited Image', use_column_width=True)
# Download the edited image
st.download_button(
label="Download Image",
data=image.tobytes(),
file_name="edited_image.png",
mime="image/png"
)