Nodes/Duanyll Nodepack/Draw Text in BBox
ComfyUI Node

Draw Text in BBox

Putting readable labels back on images

By Duanyll·Created about a year ago·Updated 4 months ago· 2
Draw Text in BBox
  • image
  • bbox
  • text_color
  • IMAGE
text
font_name

Draw Text in BBox renders a text string inside a bounding box on an image - a label, an annotation, a caption. It's the output side of the pack's bbox workflow: Parse BBox QwenVL finds a region, Draw BBox draws the outline, and this node drops the label right where it belongs. If you're building anything that overlays annotations onto images - auto-captioning pipelines, debugging detectors, batch-labeling datasets - this is the node you'll want.

The mechanism is straightforward Pillow work: it takes your image, the text, and a BBOX, picks a font sized to fit the box's height, and draws the text with a subtle shadow so it stays readable over any background. It scales text to fit, so short text fills the box and long text gets sized down rather than spilling out. That auto-fit is the part that keeps it usable in batch pipelines where you don't know the box sizes ahead of time.

The inputs

  • image - the IMAGE you're annotating.
  • text - what to draw.
  • bbox - a BBOX from any node in the pack's bbox family; the box defines where and how big the text is.
  • font_name - one of five bundled fonts: default, bold, comic, cursive_italic, and chinese. Here's the nice touch: it's automatic - if your text contains any Chinese characters, the node ignores your choice and switches to the chinese font (hei.TTF, bundled in the pack's assets) so CJK glyphs actually render instead of showing tofu boxes.
  • text_color - a wildcard-typed color. It accepts an RGB tuple; if you pass None it defaults to white.

One output: IMAGE, same size as input, with the text drawn in.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/Duanyll/duanyll_nodepack
cd duanyll_nodepack && pip install -r requirements.txt

or ComfyUI Manager → "Duanyll Nodepack" → install → restart. The fonts ship inside the pack's assets folder, so no font downloads are needed - which is more than most packs offer for CJK text. The pack's other requirements (OpenCV, kornia, insightface, matplotlib, Volcengine SDK) come along for the ride.

Gotchas

If bbox is None the node just returns the image unchanged with a printed error - no crash, but also no text, so check your bbox source if nothing appears. The shadow is fixed (no on/off), and there's no font-size input; sizing is entirely driven by the box. If you need text outside a box or with hand-set sizing, this isn't the node. But for "label the thing inside this box" - the most common annotation job in the bbox world - it's exactly right, and the built-in Chinese font support is the quiet feature that makes it a no-brainer for CJK pipelines.

Categoryduanyll/bbox

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
textSTRING
bboxBBOX
font_nameCOMBO5 options: default, bold, comic, cursive_italic, chinese
text_color*

Outputs (1)

NameTypeDescription
IMAGEIMAGE