TeamHaltmannSusanaHWCEO's picture
Update app.py
0af2a62
import streamlit as st
from PIL import Image
from PIL.ImageFilter import BLUR
# Load the image
@st.cache
def load_image(image):
return Image.open(image)
# Edit the image
@st.cache
def edit_image(image, width, height, rotate, blur):
# Resize the image
image = image.resize((width, height))
# Rotate the image
image = image.rotate(rotate)
# Blur the image
image = image.filter(ImageFilter.BLUR)
return image
# Create the main app
def main():
st.title("Photo Editor")
# Select the image to edit
image_file = st.file_uploader("Upload an image", type="jpg")
if image_file is not None:
image = load_image(image_file)
st.image(image, caption="Original Image")
# Edit the image
width = st.slider("Width", min_value=100, max_value=1000, value=400, step=100)
height = st.slider("Height", min_value=100, max_value=1000, value=400, step=100)
rotate = st.slider("Rotate", min_value=-180, max_value=180, value=0, step=10)
blur = st.checkbox("Blur")
edited_image = edit_image(image, width, height, rotate, blur)
st.image(edited_image, caption="Edited Image")
if __name__ == "__main__":
main()