GiantPandas commited on
Commit
043f8b6
·
verified ·
1 Parent(s): 1e7415a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -9
app.py CHANGED
@@ -296,15 +296,27 @@ def render_img(b64_list, idx, scale):
296
  # 以百分比形式设置 width,height 自动等比
297
  percent = scale * 100
298
 
299
- return (
300
- f'<div style="overflow:auto;border:1px solid #ccc;'
301
- f'justify-content:center;align-items:center;' # ① 横纵向居中
302
- f'width:100%;height:800px;">'
303
- f' <img src="{src}" '
304
- f' style="width:{percent}%;max-width:none;'
305
- f' height:auto;display:block;" />'
306
- f'</div>'
307
- )
 
 
 
 
 
 
 
 
 
 
 
 
308
 
309
  def files_to_b64(file, pdf_dpi: int = 200):
310
  out: list[str] = []
 
296
  # 以百分比形式设置 width,height 自动等比
297
  percent = scale * 100
298
 
299
+ if scale <= 1:
300
+ # ---------- 居中模式 ----------
301
+ return (
302
+ f'<div style="overflow:auto;border:1px solid #ccc;'
303
+ f'display:flex;justify-content:center;align-items:center;'
304
+ f'width:100%;height:800px;">'
305
+ f' <img src="{src}" '
306
+ f' style="width:{percent}%;max-width:none;'
307
+ f' height:auto;display:block;" />'
308
+ f'</div>'
309
+ )
310
+ else:
311
+ # ---------- 放大模式 ----------
312
+ return (
313
+ f'<div style="overflow:auto;border:1px solid #ccc;'
314
+ f'width:100%;height:800px;">'
315
+ f' <img src="{src}" '
316
+ f' style="width:{percent}%;max-width:none;'
317
+ f' height:auto;display:block;" />'
318
+ f'</div>'
319
+ )
320
 
321
  def files_to_b64(file, pdf_dpi: int = 200):
322
  out: list[str] = []