aryadytm commited on
Commit
d7a6e77
1 Parent(s): 46bcbf9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -64,6 +64,18 @@ if uploaded_file is not None:
64
  bytes_data = uploaded_file.getvalue()
65
  img_input = Image.open(BytesIO(bytes_data)).convert("RGBA")
66
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  stroke_width = st.slider("Brush size", 1, 100, 50)
68
 
69
  st.write("**Now draw (brush) the part of image that you want to remove.**")
@@ -121,6 +133,6 @@ if uploaded_file is not None:
121
  fmt="jpg",
122
  label="Download Image"
123
  )
124
-
125
  st.info("**TIP**: If the result is not perfect, you can download it then "
126
  "upload then remove the artifacts.")
 
64
  bytes_data = uploaded_file.getvalue()
65
  img_input = Image.open(BytesIO(bytes_data)).convert("RGBA")
66
 
67
+ # Resize the image while maintaining aspect ratio
68
+ max_size = 2000
69
+ img_width, img_height = img_input.size
70
+ if img_width > max_size or img_height > max_size:
71
+ if img_width > img_height:
72
+ new_width = max_size
73
+ new_height = int((max_size / img_width) * img_height)
74
+ else:
75
+ new_height = max_size
76
+ new_width = int((max_size / img_height) * img_width)
77
+ img_input = img_input.resize((new_width, new_height))
78
+
79
  stroke_width = st.slider("Brush size", 1, 100, 50)
80
 
81
  st.write("**Now draw (brush) the part of image that you want to remove.**")
 
133
  fmt="jpg",
134
  label="Download Image"
135
  )
136
+
137
  st.info("**TIP**: If the result is not perfect, you can download it then "
138
  "upload then remove the artifacts.")