File size: 1,212 Bytes
e1f9bab
 
0af2a62
e1f9bab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
40
41
42
43
44
45
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()