Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -228,7 +228,10 @@ async def upload_file(file: UploadFile = File(...), padding_type: str = Form(...
|
|
| 228 |
|
| 229 |
# Resize the image for display (512px by 512px)
|
| 230 |
display_img = rectangled_img.copy()
|
| 231 |
-
|
|
|
|
|
|
|
|
|
|
| 232 |
display_output = BytesIO()
|
| 233 |
display_img.save(display_output, format="JPEG")
|
| 234 |
display_output.seek(0)
|
|
@@ -247,7 +250,7 @@ async def upload_file(file: UploadFile = File(...), padding_type: str = Form(...
|
|
| 247 |
<body>
|
| 248 |
<img class="banner" src="/static/images/banner.jpg" alt="Banner" width="100%">
|
| 249 |
<h2>Image successfully rectangled!</h2>
|
| 250 |
-
<img src='data:image/jpeg;base64,{display_encoded_img}'
|
| 251 |
<p><a href="data:image/jpeg;base64,{full_size_encoded_img}" download="rectangled_image.jpg">
|
| 252 |
Download Full-Size Image</a></p>
|
| 253 |
<p><a href="/">Back</a></p>
|
|
|
|
| 228 |
|
| 229 |
# Resize the image for display (512px by 512px)
|
| 230 |
display_img = rectangled_img.copy()
|
| 231 |
+
if (padding_type=="top_bottom")
|
| 232 |
+
display_img.thumbnail((512, *)) # Resize for display
|
| 233 |
+
else
|
| 234 |
+
display_img.thumbnail((*, 512)) # Resize for display
|
| 235 |
display_output = BytesIO()
|
| 236 |
display_img.save(display_output, format="JPEG")
|
| 237 |
display_output.seek(0)
|
|
|
|
| 250 |
<body>
|
| 251 |
<img class="banner" src="/static/images/banner.jpg" alt="Banner" width="100%">
|
| 252 |
<h2>Image successfully rectangled!</h2>
|
| 253 |
+
<img src='data:image/jpeg;base64,{display_encoded_img}'/>
|
| 254 |
<p><a href="data:image/jpeg;base64,{full_size_encoded_img}" download="rectangled_image.jpg">
|
| 255 |
Download Full-Size Image</a></p>
|
| 256 |
<p><a href="/">Back</a></p>
|