Spaces:
Paused
Paused
File size: 1,231 Bytes
cab1d01 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | import streamlit as st
from PIL import Image, ImageEnhance
import io
st.title("Image Editor")
# Upload image
uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
if uploaded_file:
# Load the image
image = Image.open(uploaded_file)
st.image(image, caption="Uploaded Image", use_column_width=True)
# Options for editing
st.sidebar.header("Editing Options")
option = st.sidebar.selectbox("Choose a filter or adjustment", ["None", "Grayscale", "Brightness Adjustment"])
if option == "Grayscale":
image = image.convert("L")
st.image(image, caption="Grayscale Image", use_column_width=True)
elif option == "Brightness Adjustment":
brightness = st.sidebar.slider("Adjust Brightness", 0.1, 3.0, 1.0)
enhancer = ImageEnhance.Brightness(image)
image = enhancer.enhance(brightness)
st.image(image, caption="Brightness Adjusted Image", use_column_width=True)
# Download edited image
buf = io.BytesIO()
image.save(buf, format="PNG")
byte_im = buf.getvalue()
st.download_button(
label="Download Edited Image",
data=byte_im,
file_name="edited_image.png",
mime="image/png",
)
|