AItool commited on
Commit
260965a
·
verified ·
1 Parent(s): ccf8eb8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
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
- 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,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
- <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>
 
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>