| 937 | return () |
| 938 | |
| 939 | async def rendered_dims(html: Path) -> tuple[int, int]: |
| 940 | async with async_playwright() as p: |
| 941 | browser = await p.chromium.launch() |
| 942 | page = await browser.new_page() # no fixed viewport yet |
| 943 | resolved = html.resolve() |
| 944 | # quote_from_bytes expects bytes, so we encode the path as UTF‐8: |
| 945 | url = "file://" + quote_from_bytes(str(resolved).encode("utf-8"), safe="/:") |
| 946 | await page.goto(url, wait_until="networkidle") |
| 947 | |
| 948 | # 1) bounding-box of <body> |
| 949 | body_box = await page.eval_on_selector( |
| 950 | "body", |
| 951 | "el => el.getBoundingClientRect()") |
| 952 | w = int(body_box["width"]) |
| 953 | h = int(body_box["height"]) |
| 954 | |
| 955 | await browser.close() |
| 956 | return w, h |
| 957 | |
| 958 | |
| 959 | def html_to_png(html_abs_path, poster_width_default, poster_height_default, output_path): |