AddTextToImage
Stamp text on your images without leaving the graph
- image
- IMAGE
AddTextToImage does exactly one thing: it paints a line of text onto an image you hand it, and hands the result back as an IMAGE. No API calls, no model downloads, no secret sauce. You feed in a generated image, type a string, and out comes the same image with a caption burned onto it.
Why would you want that inside ComfyUI instead of just doing it in an editor later? Because it's reproducible. If you're batch-rendering a grid of variants, stamping a label on each keeps every image tied to its settings, and the workflow remembers the caption forever. People use it for watermarking, adding text overlays to memes before sharing, labeling training-grid rows, or dropping "AI generated" disclaimers on an output. It's also handy for annotating a preview image you're about to show someone. If you already run WAS Node Suite for post-processing, its text-overlay node does this job too - this pack is the lightweight, single-purpose alternative when you don't want a whole utility suite just to caption one image.
How it works. The node is a thin wrapper around PIL's ImageDraw.text(). It takes your IMAGE tensor, converts each frame to a PIL image, draws the string with the font and color you specify, and converts back to a tensor. Nothing clever, which is the appeal. It also loops over the whole batch, so if your input is a stack of frames from an animation, every frame gets the same caption - handy for timestamping or labeling a sequence.
The inputs that matter. Of the ten inputs, a beginner really sets four:
image- your IMAGE tensor. This is the only thing it can't work without.text- the caption. It's multiline, so hit Enter for a second line and it renders as one.font_family- here's the first trap. This dropdown is built by scanning the pack'sfontsfolder, and that folder ships empty. Out of the box the only choice isCustom, which means you must also fill incustom_font_pathwith a real .ttf/.ttc file path - the README's example isC:\Windows\Fonts\SIMLI.TTF. Drop a font file intoComfyUI/custom_nodes/add_text_2_img/fonts/and it shows up in the dropdown by filename.x,y- caption position. Leave both at 0 and the text centers itself near the bottom of the image (the code adds a 50px margin). Set any other value and it's a straight top-left-origin coordinate, clamped to the image edges. So "put it at the top-left corner" is x=0, y=0... which is also the "center it at the bottom" position. The center-bottom default wins at 0,0; for actual top-left placement nudge it to x=1, y=1.
font_size (default 38) and font_color are self-explanatory - colors take #ffffff hex or 255,255,255 RGB. The shadow trio (font_shadow_x, font_shadow_y, shadow_color) adds a drop shadow for readability, with one quirk: the code only draws it when both offsets are nonzero, so set them together or nothing happens. The single output is IMAGE, which wires straight into a Preview Image or Save Image node - that's the whole point, text in, texted image out.
Install. Two ways, both painless:
# ComfyUI Manager: search "add_text_2_img", install, restart.
# Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/yuan199696/add_text_2_img
# restart ComfyUI
The node appears under Add Node → AI_Boy → AddTextToImage. Its dependencies are pillow, numpy, and torch - all already in any working ComfyUI, so there's nothing heavy to download and no model files at all.
Troubleshooting. The most common failure by far is the empty fonts folder: you pick Custom, leave custom_font_path blank, and the node throws a FileNotFoundError at you. Either set the path or put a font in the fonts/ folder. Second: the README is in Chinese, and its example font is SIMLI - a Chinese typeface - which is a hint that if your caption contains CJK characters, you need a font with those glyphs or you'll get boxes (tofu). Drop in a CJK-capable font like Noto Sans SC. And remember the "both shadow offsets nonzero" rule above. That's about all that can go wrong with a node this small - which is exactly why it's worth having around.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| text | STRING | A cute puppy | — |
| x | INT | 00–4096 | — |
| y | INT | 00–4096 | — |
| font_size | INT | 380–100 | — |
| font_family | COMBO | 1 options: Custom | |
| font_color | STRING | #ffffff | — |
| font_shadow_x | INT | 00–20 | — |
| font_shadow_y | INT | 00–20 | — |
| shadow_color | STRING | #000000 | — |
| custom_font_pathopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |