Spaces:
Running
Running
ciover2024
commited on
Commit
•
eb4960f
1
Parent(s):
3de9fa9
Update app.py
Browse files
app.py
CHANGED
@@ -83,18 +83,19 @@ def resize_image(input_image, mask_image):
|
|
83 |
orig_image = mask_image.resize(input_image.size, Image.Resampling.LANCZOS)
|
84 |
aspect_ratio = orig_image.height / orig_image.width
|
85 |
old_width = orig_image.width
|
86 |
-
new_width = int(orig_image.width*
|
87 |
old_height = orig_image.height
|
88 |
new_height = int(new_width * aspect_ratio)
|
89 |
-
resized_image = orig_image.resize((new_width, new_height), Image.Resampling.LANCZOS)
|
90 |
|
91 |
-
left_crop = int((
|
92 |
-
right_crop =
|
93 |
-
top_crop = int((
|
94 |
-
bottom_crop =
|
95 |
-
cropped_image =
|
|
|
96 |
|
97 |
-
return
|
98 |
|
99 |
# Function to resize image (simpler interpolation method for speed)
|
100 |
def resize_to_match(input_image, output_image):
|
|
|
83 |
orig_image = mask_image.resize(input_image.size, Image.Resampling.LANCZOS)
|
84 |
aspect_ratio = orig_image.height / orig_image.width
|
85 |
old_width = orig_image.width
|
86 |
+
new_width = int(orig_image.width*0.8)
|
87 |
old_height = orig_image.height
|
88 |
new_height = int(new_width * aspect_ratio)
|
89 |
+
#resized_image = orig_image.resize((new_width, new_height), Image.Resampling.LANCZOS)
|
90 |
|
91 |
+
left_crop = int((old_width - new_width)/2)
|
92 |
+
right_crop = old_width - int((old_width - new_width) / 2)
|
93 |
+
top_crop = int((old_height - new_height)/2)
|
94 |
+
bottom_crop = old_height - int((old_height - new_height) / 2)
|
95 |
+
cropped_image = orig_image.crop((left_crop,top_crop,right_crop,bottom_crop))
|
96 |
+
return_image = cropped_image.resize(cropped_image.size, Image.Resampling.LANCZOS)
|
97 |
|
98 |
+
return return_image
|
99 |
|
100 |
# Function to resize image (simpler interpolation method for speed)
|
101 |
def resize_to_match(input_image, output_image):
|