Nodes/ComfyUI-ImageLabel/Add Label to Image ~πŸ…–
ComfyUI Node

Add Label to Image ~πŸ…–

Slap a caption on any image without leaving ComfyUI

By gremlationΒ·Created 2 years agoΒ·Updated about a year agoΒ· 6
Add Label to Image ~πŸ…–
  • image
  • image
β—„fontAileron Regularβ–Ί
β—„labelβ€”β–Ί
β—„positionβ–Ύβ–Ί
β—„text_size48β–Ί
β—„padding24β–Ί
β—„line_spacing5β–Ί
β—„text_color#fffβ–Ί
β—„background_color#000β–Ί

You've just generated the shot, it's perfect, and now you want "Model: X Β· Seed 12345" or a title caption burned in before you export. That's the one job this node does: Add Label to Image (display name "Add Label to Image ~πŸ…–", that G is author Gremlation's signature). It's a tiny single-purpose transform node - no models, no API keys, no config files - and it has one genuinely nice trick: it auto-shrinks the font until your text fits the image width. Most text-overlay nodes just let you overflow and clip; this one won't.

It's also the kind of thing you'd normally do in Photoshop or an HTML template after export. If you want the label baked into the PNG you share ("workflow included" culture and all that), doing it in the graph saves a round trip - and since the label is drawn on the output, it's part of the image you upload, not metadata that gets stripped.

How it works

Under the hood it's a short, readable Pillow script wrapped in a ComfyUI node. It converts your image tensor to a PIL image, measures your label text at the requested text_size, and - here's the part to know - if the text is wider than the image, it keeps dropping the font size 1px at a time until it fits, with an 8px floor. It then makes a new canvas the same width as your image, draws the label centered and multiline in your chosen colors, and pastes your original image above or below the label bar. It never scales or crops the original; the output is simply the original height plus the label bar. Keep that in mind if you need an exact aspect ratio for a gallery or posting - the label changes your dimensions.

Dependencies are torch, torchvision, and Pillow>=8 - all of which every ComfyUI install already has, so there's nothing heavy to fetch and nothing to download.

Inputs and output

Every input is on the node's "required" side, but you'll actually touch maybe four of them:

  • image - what you're labeling. Feed it one decoded image; more on that below.
  • label (multiline string) - your text. Multiline means you can type several lines and it centers the block.
  • position - top or bottom, i.e. where the label bar goes.
  • text_size (default 48) - your starting font size; remember it auto-shrinks to fit.
  • padding (24), line_spacing (5) - spacing around and between the text.
  • text_color / background_color - hex strings, defaults #fff on #000, so a white-on-black credit bar by default.
  • font - the dropdown; this is where the one install quirk lives (below).

The single output, image (IMAGE type), is what you wire into a preview or save node - or into another transform if you want to resize back to your original dimensions after the label bar was added.

Installing it

The standard three ways, straight from the README:

# ComfyUI Manager: Custom Nodes Manager -> search "ComfyUI-ImageLabel" -> Install
# or comfy-cli:
comfy node install comfyui-imagelabel
# or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/gremlation/ComfyUI-ImageLabel
pip install -r ComfyUI-ImageLabel/requirements.txt

Then restart ComfyUI. The pip install step is effectively a no-op since the requirements are already satisfied, so this is about as painless as a custom node gets.

Where people get burned

  • It's single-image only. The node does image.squeeze(0) on the input, so feed it a batch of several images and it dies with a tensor permute shape error. Wire in one VAE decode at a time.
  • Its output tensor is shaped [1,1,H,W,C] instead of ComfyUI's standard [B,H,W,C] - an extra leading dimension that's a quirk of this release. Most nodes shrug it off, but a strict save path can throw TypeError: Cannot handle this data type. If you see that exact error, it's the node, not your graph.
  • The font list often collapses to just "Aileron Regular" (Pillow's built-in font). The bundled Roboto fonts are looked up from a path hardcoded as lowercase comfyui-imagelabel, but git clone creates ComfyUI-ImageLabel. On case-sensitive filesystems (Linux, macOS) that mismatch means no Roboto - on Windows it works fine. Harmless, but it's why your font dropdown looks emptier than the repo.

It's a small pack from a single author, Apache-2.0 licensed, with no real community chatter to lean on - which is fine, because the source is short enough to read in a minute. For "put text on my image before export," this is the one I'd reach for.

Categoryimage/transform

Inputs (9)

NameTypeDefaultDescription
imageIMAGEβ€”
fontCOMBOAileron Regular1 options: Aileron Regular
labelSTRINGβ€”
positionCOMBO2 options: top, bottom
text_sizeINT48β€”
paddingINT24β€”
line_spacingINT5β€”
text_colorSTRING#fffβ€”
background_colorSTRING#000β€”

Outputs (1)

NameTypeDescription
imageIMAGEβ€”