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