Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -296,15 +296,27 @@ def render_img(b64_list, idx, scale):
|
|
| 296 |
# 以百分比形式设置 width,height 自动等比
|
| 297 |
percent = scale * 100
|
| 298 |
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 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] = []
|