Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,6 +26,9 @@ if uploaded_file:
|
|
| 26 |
sharpness = st.sidebar.slider("Sharpness", 0.1, 3.0, 1.0)
|
| 27 |
color = st.sidebar.slider("Color Saturation", 0.1, 3.0, 1.0)
|
| 28 |
|
|
|
|
|
|
|
|
|
|
| 29 |
# Filters
|
| 30 |
if st.sidebar.checkbox("Apply Filters"):
|
| 31 |
filter_option = st.sidebar.selectbox("Select a Filter", ["None", "BLUR", "DETAIL", "EDGE_ENHANCE", "SMOOTH"])
|
|
@@ -65,21 +68,25 @@ if uploaded_file:
|
|
| 65 |
if st.sidebar.checkbox("Add Watermark"):
|
| 66 |
watermark_text = st.sidebar.text_input("Watermark Text", "My Watermark")
|
| 67 |
draw = ImageDraw.Draw(image)
|
| 68 |
-
font = ImageFont.
|
| 69 |
width, height = image.size
|
| 70 |
text_width, text_height = draw.textsize(watermark_text, font)
|
| 71 |
x, y = width - text_width - 10, height - text_height - 10
|
| 72 |
draw.text((x, y), watermark_text, font=font, fill=(255, 255, 255, 128))
|
| 73 |
|
| 74 |
# Enhance Image
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
# Display Enhanced Image
|
| 85 |
st.image(image, caption="Enhanced Image", use_column_width=True)
|
|
|
|
| 26 |
sharpness = st.sidebar.slider("Sharpness", 0.1, 3.0, 1.0)
|
| 27 |
color = st.sidebar.slider("Color Saturation", 0.1, 3.0, 1.0)
|
| 28 |
|
| 29 |
+
# Debugging print for color value
|
| 30 |
+
st.write(f"Color Value: {color}")
|
| 31 |
+
|
| 32 |
# Filters
|
| 33 |
if st.sidebar.checkbox("Apply Filters"):
|
| 34 |
filter_option = st.sidebar.selectbox("Select a Filter", ["None", "BLUR", "DETAIL", "EDGE_ENHANCE", "SMOOTH"])
|
|
|
|
| 68 |
if st.sidebar.checkbox("Add Watermark"):
|
| 69 |
watermark_text = st.sidebar.text_input("Watermark Text", "My Watermark")
|
| 70 |
draw = ImageDraw.Draw(image)
|
| 71 |
+
font = ImageFont.load_default() # Use default font if arial.ttf doesn't work
|
| 72 |
width, height = image.size
|
| 73 |
text_width, text_height = draw.textsize(watermark_text, font)
|
| 74 |
x, y = width - text_width - 10, height - text_height - 10
|
| 75 |
draw.text((x, y), watermark_text, font=font, fill=(255, 255, 255, 128))
|
| 76 |
|
| 77 |
# Enhance Image
|
| 78 |
+
try:
|
| 79 |
+
enhancer = ImageEnhance.Brightness(image)
|
| 80 |
+
image = enhancer.enhance(brightness)
|
| 81 |
+
enhancer = ImageEnhance.Contrast(image)
|
| 82 |
+
image = enhancer.enhance(contrast)
|
| 83 |
+
enhancer = ImageEnhance.Sharpness(image)
|
| 84 |
+
image = enhancer.enhance(sharpness)
|
| 85 |
+
enhancer = ImageEnhance.Color(image)
|
| 86 |
+
image = enhancer.enhance(color) # Enhance color saturation
|
| 87 |
+
|
| 88 |
+
except Exception as e:
|
| 89 |
+
st.write(f"Error during enhancement: {e}")
|
| 90 |
|
| 91 |
# Display Enhanced Image
|
| 92 |
st.image(image, caption="Enhanced Image", use_column_width=True)
|