Nodes/ComfyUI-Muye-nodes/文字叠加图像
ComfyUI Node

文字叠加图像

Draw real text onto an image, and get the text mask for free

By muyexiuluo·Created about a year ago·Updated 23 days ago· 89
文字叠加图像
  • 图像
  • 文字颜色
  • 图像
  • 文字遮罩
文本
字体C
字体大小128
字体颜色
排版横向
X位置384
Y位置512

TextOverlayImage is the "put words on the picture" node - but it's smarter than it looks, because it hands you the text mask as a second output, not just the composited image. You give it an image and some text; it renders the text with a real font (a dropdown of your system's installed fonts - it scans the OS font directories at load time), colors it, positions it, and returns both the new image and a MASK of exactly where the text pixels are. That mask output is the sleeper feature: you can use it to drive a blend, punch the text out of something else, or composite the text onto a different image entirely.

Practical uses: burning a title or label onto a generated frame, adding a caption for a dataset preview, watermark-style branding (though the pack's AddImageWatermark is the dedicated stamp node - this one is for text). And since it's deterministic and instant, it slots into batch pipelines without slowing anything down - this is the post-processing layer's philosophy in miniature: a compositing op, not a model pass.

The controls you'll actually touch:

  • 文本 - the string to draw. Long text just overflows the canvas; there's no wrapping, so keep it short or add newlines yourself.
  • 字体 / 字体大小 - the font list is whatever's installed on your system. Big gotcha: if your text is Chinese and the font you pick is a Latin-only face like DejaVu, you'll get tofu boxes. The node prefers NotoSansSC-VF when present (a CJK-capable font) - install one if you're rendering Chinese and seeing squares.
  • 字体颜色 - black/white/gray/red/green/blue from the dropdown, or connect the optional 文字颜色 socket for an arbitrary RGB value (it overrides the dropdown).
  • 排版 - 横向 (horizontal) or 纵向 (vertical, one character per line).
  • X位置 / Y位置 - and here's a subtlety: the position is the center of the text, not its top-left corner. The node measures the text and centers it on (X, Y). So X=384, Y=512 on a 768-wide image puts the text dead center.

Outputs: 图像 (the composited IMAGE) and 文字遮罩 (the MASK, 1 where text pixels are, 0 elsewhere - white = text).

Install

ComfyUI Manager → search "muye" → install "ComfyUI-Muye-nodes", restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/muyexiuluo/ComfyUI-Muye-nodes
cd ComfyUI-Muye-nodes
pip install -r requirements.txt

then restart. Deps: torch + Pillow only. The README's manual block references an older ComfyUI_Muye.git URL; use the -nodes one above. Display name is 文字叠加图像. If the node's missing, check the console for [Muye] Failed to load module.

Common issues

Two things get people. The center-anchored positioning (you'll wonder why the text sits off to one side until you remember X/Y is the middle), and the CJK-font tofu problem. Also, the text is drawn as a flat solid color over the image - if you want semi-transparency, take the 文字遮罩 output and blend it yourself with MuyeImageBlendingMode, which is exactly the kind of pairing this pack encourages.

CategoryMuye/文本

Inputs (9)

NameTypeDefaultDescription
图像IMAGE
文本STRING
字体COMBOC47 options: C059-BdIta, C059-Bold, C059-Italic, C059-Roman, D050000L, DejaVuSans, +41
字体大小INT1281–512
字体颜色COMBO6 options: 黑, 白, 灰, 红, 绿, 蓝
排版COMBO横向2 options: 横向, 纵向
X位置INT384
Y位置INT512
文字颜色opt*

Outputs (2)

NameTypeDescription
图像IMAGE
文字遮罩MASK