Bakht11 commited on
Commit
53e2356
·
verified ·
1 Parent(s): ed8b054

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py CHANGED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PIL import Image, ImageEnhance
3
+ import numpy as np
4
+
5
+ # Title of the app
6
+ st.title("Image Enhancer Application")
7
+
8
+ # File uploader to upload the image
9
+ uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
10
+
11
+ if uploaded_file is not None:
12
+ # Open the image
13
+ image = Image.open(uploaded_file)
14
+
15
+ # Display the original image
16
+ st.image(image, caption='Original Image', use_column_width=True)
17
+
18
+ # Brightness adjustment
19
+ st.sidebar.header("Adjust Brightness")
20
+ brightness = st.sidebar.slider("Brightness", 0.0, 2.0, 1.0)
21
+ enhancer_brightness = ImageEnhance.Brightness(image)
22
+ enhanced_image_brightness = enhancer_brightness.enhance(brightness)
23
+
24
+ # Contrast adjustment
25
+ st.sidebar.header("Adjust Contrast")
26
+ contrast = st.sidebar.slider("Contrast", 0.0, 2.0, 1.0)
27
+ enhancer_contrast = ImageEnhance.Contrast(enhanced_image_brightness)
28
+ enhanced_image_contrast = enhancer_contrast.enhance(contrast)
29
+
30
+ # Show the enhanced image
31
+ st.image(enhanced_image_contrast, caption='Enhanced Image', use_column_width=True)
32
+
33
+ # Option to download the enhanced image
34
+ st.sidebar.download_button("Download Enhanced Image",
35
+ data=np.array(enhanced_image_contrast).tobytes(),
36
+ file_name="enhanced_image.png",
37
+ mime="image/png")