Image-Enhancer / app.py
Bakht11's picture
Update app.py
53e2356 verified
raw
history blame
1.42 kB
import streamlit as st
from PIL import Image, ImageEnhance
import numpy as np
# Title of the app
st.title("Image Enhancer Application")
# File uploader to upload the image
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
if uploaded_file is not None:
# Open the image
image = Image.open(uploaded_file)
# Display the original image
st.image(image, caption='Original Image', use_column_width=True)
# Brightness adjustment
st.sidebar.header("Adjust Brightness")
brightness = st.sidebar.slider("Brightness", 0.0, 2.0, 1.0)
enhancer_brightness = ImageEnhance.Brightness(image)
enhanced_image_brightness = enhancer_brightness.enhance(brightness)
# Contrast adjustment
st.sidebar.header("Adjust Contrast")
contrast = st.sidebar.slider("Contrast", 0.0, 2.0, 1.0)
enhancer_contrast = ImageEnhance.Contrast(enhanced_image_brightness)
enhanced_image_contrast = enhancer_contrast.enhance(contrast)
# Show the enhanced image
st.image(enhanced_image_contrast, caption='Enhanced Image', use_column_width=True)
# Option to download the enhanced image
st.sidebar.download_button("Download Enhanced Image",
data=np.array(enhanced_image_contrast).tobytes(),
file_name="enhanced_image.png",
mime="image/png")