Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -62,8 +62,8 @@ def resize_image(image, output_size=(1024, 1024)):
|
|
62 |
# Resize then crop if the original image is larger
|
63 |
if image_aspect > target_aspect:
|
64 |
# Resize the image to match the target height, maintaining aspect ratio
|
65 |
-
new_height = output_size[1]
|
66 |
-
new_width = int(new_height * image_aspect)
|
67 |
resized_image = image.resize((new_width, new_height), Image.LANCZOS)
|
68 |
# Calculate coordinates for cropping
|
69 |
left = (new_width - output_size[0]) / 2
|
@@ -72,8 +72,8 @@ def resize_image(image, output_size=(1024, 1024)):
|
|
72 |
bottom = output_size[1]
|
73 |
else:
|
74 |
# Resize the image to match the target width, maintaining aspect ratio
|
75 |
-
new_width = output_size[0]
|
76 |
-
new_height = int(new_width / image_aspect)
|
77 |
resized_image = image.resize((new_width, new_height), Image.LANCZOS)
|
78 |
# Calculate coordinates for cropping
|
79 |
left = 0
|
|
|
62 |
# Resize then crop if the original image is larger
|
63 |
if image_aspect > target_aspect:
|
64 |
# Resize the image to match the target height, maintaining aspect ratio
|
65 |
+
new_height = output_size[1]*2
|
66 |
+
new_width = int(new_height * image_aspect)
|
67 |
resized_image = image.resize((new_width, new_height), Image.LANCZOS)
|
68 |
# Calculate coordinates for cropping
|
69 |
left = (new_width - output_size[0]) / 2
|
|
|
72 |
bottom = output_size[1]
|
73 |
else:
|
74 |
# Resize the image to match the target width, maintaining aspect ratio
|
75 |
+
new_width = output_size[0]
|
76 |
+
new_height = (int(new_width / image_aspect))*2
|
77 |
resized_image = image.resize((new_width, new_height), Image.LANCZOS)
|
78 |
# Calculate coordinates for cropping
|
79 |
left = 0
|