Update utils.py
Browse files
utils.py
CHANGED
|
@@ -9,7 +9,7 @@ def resize_image_to_1mp(image):
|
|
| 9 |
"""Resizes image to approx 1MP (e.g., 1024x1024) preserving aspect ratio."""
|
| 10 |
image = image.convert("RGB")
|
| 11 |
w, h = image.size
|
| 12 |
-
target_pixels =
|
| 13 |
aspect_ratio = w / h
|
| 14 |
|
| 15 |
# Calculate new dimensions
|
|
@@ -21,6 +21,6 @@ def resize_image_to_1mp(image):
|
|
| 21 |
new_h = (new_h // 64) * 64
|
| 22 |
|
| 23 |
if new_w == 0 or new_h == 0:
|
| 24 |
-
new_w, new_h =
|
| 25 |
|
| 26 |
return image.resize((new_w, new_h), Image.LANCZOS)
|
|
|
|
| 9 |
"""Resizes image to approx 1MP (e.g., 1024x1024) preserving aspect ratio."""
|
| 10 |
image = image.convert("RGB")
|
| 11 |
w, h = image.size
|
| 12 |
+
target_pixels = 1024 * 1024
|
| 13 |
aspect_ratio = w / h
|
| 14 |
|
| 15 |
# Calculate new dimensions
|
|
|
|
| 21 |
new_h = (new_h // 64) * 64
|
| 22 |
|
| 23 |
if new_w == 0 or new_h == 0:
|
| 24 |
+
new_w, new_h = 1024, 1024 # Fallback
|
| 25 |
|
| 26 |
return image.resize((new_w, new_h), Image.LANCZOS)
|