XB-BOX - 🤖 漫画文字渲染 (全自动带涂改液)
Erase AI gibberish in comic bubbles and typeset real dialogue
- image
- 图像
- 检测信息
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:
- Grayscale the image (inverting it if you enable
invert_modefor dark-comic bubbles). - Morphological closing - a
morph_close_sizekernel (default 15) blurs over the noise and ghost-text textures inside bubbles so they read as solid white blobs. - Threshold at
white_threshold(default 220) to get a binary mask. - Erode to separate bubbles that are touching (
erode_iterations), then close again to patch the holes. - Find contours and filter: drop anything under
min_bubble_area, and withshape_filter_enabledreject long thin regions (white t-shirts, text boxes) via amin_extent/max_aspect_ratioprior. - Sort the survivors by
sort_mode(auto,top_to_bottom,left_to_right,largest_first). - The correction fluid step: if
auto_clear_bubbleis 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
trueunless 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_rightifautoorders your bubbles wrong. - font_name / font_size / text_color -
msyh.ttcorsimhei.ttfare 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_sizeand/or lowerwhite_threshold. - Wrong things get text - white shirts, panels, and margins love to masquerade as bubbles. Raise
min_bubble_area, keepshape_filter_enabledon, and bumpmin_extenta bit. - Text missing from some bubbles - fewer bubbles detected than dialogue lines means your
|count doesn't match; check the 检测信息 output. - Font warnings -
msyh.ttcis a Windows font; on Linux/macOS install one of the CJK fonts or pointfont_nameat 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.
Inputs (16)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| text | STRING | 台词,竖线 | 分隔。如: 台词1 | 台词2 | |
| font_name | STRING | msyh.ttc | 字体名或路径,如 msyh.ttc / simhei.ttf |
| font_size | INT | 368–500 | — |
| text_color | STRING | #000000 | — |
| bubble_margin | INT | 150–200 | — |
| auto_clear_bubble | BOOLEAN | true | 数字涂改液: 用纯白填满气泡内部,彻底抹除 AI 鬼影乱码后再印字 |
| white_threshold | INT | 220160–255 | 白色阈值。降低可检测带光影的气泡 |
| min_bubble_area | INT | 5000500–1000000 | — |
| sort_mode | COMBO | auto | 4 options: auto, top_to_bottom, left_to_right, largest_first |
| invert_mode | BOOLEAN | false | 暗黑模式: 取反后检测深色气泡 |
| shape_filter_enabled | BOOLEAN | true | 形状过滤: 排除白T恤等长条形误检 |
| min_extent | FLOAT | 0.400.1–1 | — |
| max_aspect_ratio | FLOAT | 3.51–10 | — |
| erode_iterations | INT | 10–5 | 边界分离: 腐蚀迭代,分离粘连气泡 |
| morph_close_size | INT | 153–51 | 形态学内核尺寸。增大可填平气泡内的噪点和残影 |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| 图像 | IMAGE | — |
| 检测信息 | STRING | — |