Nodes/XB_ToolBox/XB-BOX - 🤖 漫画文字渲染 (全自动带涂改液)
ComfyUI Node

XB-BOX - 🤖 漫画文字渲染 (全自动带涂改液)

Erase AI gibberish in comic bubbles and typeset real dialogue

By wjluoxiao·Created 5 months ago·Updated 6 days ago· 302
XB-BOX - 🤖 漫画文字渲染 (全自动带涂改液)
  • image
  • 图像
  • 检测信息
text
font_namemsyh.ttc
font_size36
text_color#000000
bubble_margin15
auto_clear_bubbletrue
white_threshold220
min_bubble_area5000
sort_modeauto
invert_modefalse
shape_filter_enabledtrue
min_extent0.40
max_aspect_ratio3.5
erode_iterations1
morph_close_size15

Ask a diffusion model to draw a comic and it nails the art but renders the speech bubbles as unreadable squiggles - text is still the one thing image models can't do. XB_AutoBubbleTextRenderer is the automated fix for that: it scans the image for white speech bubbles, paints over whatever garbage the model drew inside them (the pack calls it 涂改液, "correction fluid"), and typesets your real dialogue in their place. One node, image in, clean comic out.

It's the headline comic tool in XB_ToolBox, and it's honestly the reason a lot of people install the pack at all. Pair it with XB_ComicPromptParser upstream - which strips dialogue out of your prompt so the model never draws those characters in the first place - and you have a full "generate the art, let us write the words" pipeline.

How it works

This is a pure OpenCV computer-vision pipeline, no AI involved at the render step:

  1. Grayscale the image (inverting it if you enable invert_mode for dark-comic bubbles).
  2. Morphological closing - a morph_close_size kernel (default 15) blurs over the noise and ghost-text textures inside bubbles so they read as solid white blobs.
  3. Threshold at white_threshold (default 220) to get a binary mask.
  4. Erode to separate bubbles that are touching (erode_iterations), then close again to patch the holes.
  5. Find contours and filter: drop anything under min_bubble_area, and with shape_filter_enabled reject long thin regions (white t-shirts, text boxes) via a min_extent / max_aspect_ratio prior.
  6. Sort the survivors by sort_mode (auto, top_to_bottom, left_to_right, largest_first).
  7. The correction fluid step: if auto_clear_bubble is on, each detected bubble interior is filled pure white - wiping any AI gibberish - before your text is rendered inside with a margin (bubble_margin).

Your dialogue goes in the text field separated by |, so 台词1 | 台词2 | 台词3 renders line by line across the detected bubbles in sort order.

The inputs that matter

  • text - your dialogue, |-separated, one line per bubble.
  • auto_clear_bubble - keep it true unless your source already has clean white bubbles; this is what kills the ghost text.
  • white_threshold (160–255) - lower it if your bubbles have lighting/shadows and aren't being detected.
  • min_bubble_area (default 5000) - raise it if random white regions keep getting picked up as bubbles.
  • sort_mode - set to top_to_bottom/left_to_right if auto orders your bubbles wrong.
  • font_name / font_size / text_color - msyh.ttc or simhei.ttf are the typical defaults; the node looks in the system font path.

Outputs: 图像 (the rendered IMAGE) and 检测信息 - a STRING log of what it found and filtered, which is your debugging best friend when a bubble gets missed.

Installing

Comes with XB_ToolBox (ComfyUI Manager → search XB_ToolBox, or git clone https://github.com/WJLUOXIAO/XB_ToolBox.git into custom_nodes), then restart. This node needs opencv-python - the code raises a clear ImportError telling you to pip install opencv-python if it's missing, and the pack lists it in requirements.txt.

Common issues

  • Bubbles not detected - the classic cause is texture/noise inside the bubble breaking the white blob. Raise morph_close_size and/or lower white_threshold.
  • Wrong things get text - white shirts, panels, and margins love to masquerade as bubbles. Raise min_bubble_area, keep shape_filter_enabled on, and bump min_extent a bit.
  • Text missing from some bubbles - fewer bubbles detected than dialogue lines means your | count doesn't match; check the 检测信息 output.
  • Font warnings - msyh.ttc is a Windows font; on Linux/macOS install one of the CJK fonts or point font_name at a path you have.

It's not perfect on dense, artistic pages - this is blob-detection with training wheels, and it will occasionally pick the wrong region. But for clean webtoon-style panels it turns a 20-minute manual Photoshop job into a queue and walk away.

CategoryXB_ToolBox/Comic

Inputs (16)

NameTypeDefaultDescription
imageIMAGE
textSTRING台词,竖线 | 分隔。如: 台词1 | 台词2
font_nameSTRINGmsyh.ttc字体名或路径,如 msyh.ttc / simhei.ttf
font_sizeINT368–500
text_colorSTRING#000000
bubble_marginINT150–200
auto_clear_bubbleBOOLEANtrue数字涂改液: 用纯白填满气泡内部,彻底抹除 AI 鬼影乱码后再印字
white_thresholdINT220160–255白色阈值。降低可检测带光影的气泡
min_bubble_areaINT5000500–1000000
sort_modeCOMBOauto4 options: auto, top_to_bottom, left_to_right, largest_first
invert_modeBOOLEANfalse暗黑模式: 取反后检测深色气泡
shape_filter_enabledBOOLEANtrue形状过滤: 排除白T恤等长条形误检
min_extentFLOAT0.400.1–1
max_aspect_ratioFLOAT3.51–10
erode_iterationsINT10–5边界分离: 腐蚀迭代,分离粘连气泡
morph_close_sizeINT153–51形态学内核尺寸。增大可填平气泡内的噪点和残影

Outputs (2)

NameTypeDescription
图像IMAGE
检测信息STRING