MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / html_to_png

Function html_to_png

utils/wei_utils.py:959–976  ·  view source on GitHub ↗
(html_abs_path, poster_width_default, poster_height_default, output_path)

Source from the content-addressed store, hash-verified

957
958
959def html_to_png(html_abs_path, poster_width_default, poster_height_default, output_path):
960 html_file = html_abs_path
961
962 try:
963 w, h = asyncio.run(rendered_dims(html_file))
964 except:
965 w = poster_width_default
966 h = poster_height_default
967
968 with sync_playwright() as p:
969 path_posix = Path(html_file).resolve().as_posix()
970
971 file_url = "file://" + quote(path_posix, safe="/:")
972 browser = p.chromium.launch()
973 page = browser.new_page(viewport={"width": w, "height": h})
974 page.goto(file_url, wait_until='networkidle')
975 page.screenshot(path=output_path, full_page=True)
976 browser.close()
977
978def account_token(response):
979 input_token = response.info['usage']['prompt_tokens']

Callers 2

Calls 3

rendered_dimsFunction · 0.85
runMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected