🐟Template To Image
Type a few text fields, get a finished poster — real HTML rendered by real Chrome
- image1
- image2
- image3
- image
- width
- height
This is the node people actually come to this pack for. Feed it a background image and a handful of text strings, and out the other end you get a fully typeset poster as a real ComfyUI IMAGE tensor - no PIL fiddling, no compositing nodes, no fighting with fonts. The pack's README leans hard on this one, and it shows: it's got a whole workflow image for it.
The trick is that the layout is done in actual HTML and CSS, by a designer, not by you. TemplateToImage is the "turn text boxes into a rendered design" node that ComfyUI is otherwise missing. If you've ever wanted to automate greeting cards, event posters, or those Chinese solar-term (节气) share images, this is the fastest path. You wire the output straight into a Save Image node, or VAE-encode it if you want to feed the rendered design back into the diffusion loop.
How it works
Under the hood it's the pack's shared Selenium base: the node takes a Jinja2 HTML template, stuffs your text and images into it, writes the rendered page to a temporary HTML file next to the template, and screenshots it with headless Chrome at your chosen width and height. The IMAGE you get is a screenshot of a real browser rendering - that's why the typography, kerning, and gradients all look right.
One thing to know: images you pass in get saved as imageN.png inside the pack's template folder so the HTML can reference them, then deleted after the screenshot. That means the pack directory needs write permission, and it's why a background image sometimes doesn't show up on a read-only install.
The inputs that matter
- template_file - pick your design:
templates/jieqi/template.html(the solar-term poster) ortemplates/happy_new_year/template.html(the bilingual new-year card). That's the whole template library, so far. - width / height - default 1242×2208, the jieqi template's native poster size. Range is 64–4096.
- wait_time_seconds - how long Chrome waits before shooting, default 0.5.
The text1–text7 and image1–image3 slots mean different things per template. For jieqi: text1 is the big vertical title, text2 the date line, text3 the blessing, and text4 is the dark overlay's opacity (a number like 0.3). image1 is the background photo. For happy_new_year: text1 logo, text2 domain, text3/text4 the English and Chinese greetings, text5/text6 the two bottom lines, text7 the big "HAPPY NEW YEAR", and image2 is a QR code.
Watch for this: the README says happy_new_year takes eight text fields, but the node actually exposes seven. The template reads an eighth value (its overlay opacity) that you can't reach from the UI, so that one keeps its default 0.3. Minor, but it'll save you a confused five minutes.
Outputs
image (the rendered IMAGE), plus width and height as INTs. Those last two are handy - plug them into an EmptyLatent or a conditioning size so downstream nodes match the poster exactly.
Installing
Via ComfyUI Manager, search "ComfyUI-Html2Image". Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/liuqianhonga/ComfyUI-Html2Image.git
pip install -r requirements.txt
Then restart ComfyUI. Dependencies are selenium, webdriver_manager, jinja2, and Pillow (torch and numpy are already there). The one dependency nobody tells you about: you need Google Chrome installed on the machine. Selenium launches a real Chrome binary - ChromeDriverManager only fetches the driver, not the browser. The README doesn't mention this, and it's the #1 way this pack fails on a fresh box.
Troubleshooting
- First run is slow - webdriver_manager downloads chromedriver once. Needs internet.
- White/blank output - the template rendered but nothing painted; usually a missing relative asset or a typo in
template_file. - Background image missing - the node wrote
image1.pnginto the pack folder and couldn't; check write permission onComfyUI/custom_nodes/ComfyUI-Html2Image. - "SessionNotCreated" / no such binary - Chrome isn't installed. Install Chromium/Chrome and retry.
It's a narrow tool, but for "generate a finished poster from text fields" it's the smoothest thing in the pack.
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| template_file | STRING | templates/jieqi/template.html | — |
| width | INT | 124264–4096 | — |
| height | INT | 220864–4096 | — |
| wait_time_seconds | FLOAT | 0.50 | — |
| text1opt | STRING | — | |
| text2opt | STRING | — | |
| text3opt | STRING | — | |
| text4opt | STRING | — | |
| text5opt | STRING | — | |
| text6opt | STRING | — | |
| text7opt | STRING | — | |
| image1opt | IMAGE | — | |
| image2opt | IMAGE | — | |
| image3opt | IMAGE | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| width | INT | — |
| height | INT | — |