image_editor / app.py
harriskr14's picture
Upload 3 files
4016dce verified
Raw
History Blame Contribute Delete
1.37 kB
import streamlit as st
from PIL import Image, ImageFilter
st.markdown("<h1 style='text-align: center; color: green;'>🖼️ Image Editor 🖼️</h1>", unsafe_allow_html=True)
st.markdown("---")
image = st.file_uploader("Upload an Image", type=["jpg", "jpeg", "png"])
size = st.empty()
if image:
img = Image.open(image)
st.title("Information", text_alignment="center")
st.markdown(f"##### Image Name: {image.name}", unsafe_allow_html=True)
st.markdown(f"##### Image Size: {img.size}", unsafe_allow_html=True)
st.markdown(f"##### Image Format: {img.format}", unsafe_allow_html=True)
st.title("Resizing", text_alignment="center")
width = st.number_input("Width", min_value=1, value=img.width)
height = st.number_input("Height", min_value=1, value=img.height)
st.title("Rotation", text_alignment="center")
angle = st.slider("Angle", min_value=0, max_value=360, value=0)
st.title("Filters", text_alignment="center")
filter_option = st.selectbox("Choose a filter", ["None", "BLUR", "CONTOUR", "DETAIL", "EDGE_ENHANCE", "EMBOSS", "SHARPEN"])
btn = st.button("Apply Edits")
if btn:
edited_img = img.resize((width, height)).rotate(angle)
if filter_option != "None":
edited_img = edited_img.filter(getattr(ImageFilter, filter_option))
st.image(edited_img, caption="Edited Image")