Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -51,6 +51,28 @@ if uploaded_image:
|
|
| 51 |
width = st.sidebar.number_input("Width", value=image.width, step=1)
|
| 52 |
height = st.sidebar.number_input("Height", value=image.height, step=1)
|
| 53 |
|
| 54 |
-
# Apply
|
| 55 |
enhancer_brightness = ImageEnhance.Brightness(image)
|
| 56 |
-
image = enhancer_brightness.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
width = st.sidebar.number_input("Width", value=image.width, step=1)
|
| 52 |
height = st.sidebar.number_input("Height", value=image.height, step=1)
|
| 53 |
|
| 54 |
+
# Apply Brightness
|
| 55 |
enhancer_brightness = ImageEnhance.Brightness(image)
|
| 56 |
+
image = enhancer_brightness.enhance(brightness)
|
| 57 |
+
|
| 58 |
+
# Apply Contrast
|
| 59 |
+
enhancer_contrast = ImageEnhance.Contrast(image)
|
| 60 |
+
image = enhancer_contrast.enhance(contrast)
|
| 61 |
+
|
| 62 |
+
# Apply Sharpness
|
| 63 |
+
enhancer_sharpness = ImageEnhance.Sharpness(image)
|
| 64 |
+
image = enhancer_sharpness.enhance(sharpness)
|
| 65 |
+
|
| 66 |
+
# Resize image
|
| 67 |
+
image = image.resize((int(width), int(height)))
|
| 68 |
+
|
| 69 |
+
# Display edited image
|
| 70 |
+
st.image(image, caption="Edited Image", use_column_width=True)
|
| 71 |
+
|
| 72 |
+
# Convert to bytes for download
|
| 73 |
+
img_bytes = io.BytesIO()
|
| 74 |
+
image.save(img_bytes, format="PNG")
|
| 75 |
+
img_bytes = img_bytes.getvalue()
|
| 76 |
+
|
| 77 |
+
# Download button
|
| 78 |
+
st.download_button("Download Image", data=img_bytes, file_name="edited_image.png", mime="image/png")
|