Spaces:
Runtime error
Runtime error
import streamlit as st | |
from PIL import Image | |
# Load the image | |
def load_image(image): | |
return Image.open(image) | |
# Edit the image | |
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() | |