MLTask Utils Text Image Generator
Type a slogan, get a post-ready image — and the only node in this pack that's fully offline
- text_image
- text_image_mask
- text_image_inverted
- text_image_mask_inverted
Every other node in the MLTask pack is busy phoning home to a social network API. This one is the quiet exception: MLTaskUtilsTextImageGenerator renders text to an image locally, no token, no network, no subscription. If you've ever wanted a workflow that bakes a caption or a slogan into the poster itself - a "Type your prompt, get a shareable card" pipeline - this is the node that makes it possible. The pack's own example workflow uses it: text in, text_image out, straight into SocialManMediaToPoster and then out to every network.
The mechanism is plain PIL, which is both the point and the ceiling. It takes your text, wraps it to fit the width, centers each line, and draws it with a font you pick from your system's installed typefaces. It does this twice in one run: once as black text on a white background (the text_image output) and once inverted, white text on black (text_image_inverted). Same text, same layout, two finishes - you grab whichever suits the post.
The inputs that matter
- text (required, multiline) - what gets drawn. Keep it short; long paragraphs wrap into a wall of centered lines.
- width / height (defaults 512×512) - the canvas size.
- font_size (default 100) - big by default, which is right for a slogan card.
- font_name - a dropdown of fonts picked up from your system via matplotlib's font manager (44 choices in a typical install, all the DejaVu family plus whatever else you have). Note it's by filename, so you'll see
DejaVuSans-Bold.ttfrather than a friendly name. - offset_x / offset_y - nudges the centered text block around the canvas. Defaults to 0, dead center.
Four outputs come out: text_image and text_image_inverted (both IMAGE), plus text_image_mask and text_image_mask_inverted (both MASK). Here's the honest catch: those mask outputs are effectively blank. The node derives a mask from the image's alpha channel, and a plain RGB render has no alpha, so you get back an empty zero mask. Don't design around them - treat the two images as the real outputs and composite them directly. If you actually need a text mask, threshold the image in a dedicated mask node; don't expect this one to deliver it.
A few practical notes. The font list comes from matplotlib, and Common/Utils.py imports it at module load - if the whole pack ever fails to import with a matplotlib error, that's why (pip install matplotlib fixes it). There's no color picker yet - the white/black pairing is fixed, and the source has commented-out color widgets that never shipped. If you need colored text, render here and tint downstream. And the drawing is purely PIL, so it's resolution-safe: make the canvas match your final poster size, then it's just an image like any other in the graph.
Installing it
It ships inside the MLTask_ComfyUI pack, under MLTask/SocialMan/Utils. ComfyUI Manager: search MLTask_ComfyUI, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/misterjoessef/MLTask_ComfyUI
The pack's listed dependencies are just requests and aiohttp; matplotlib, numpy, and Pillow are the real requirements, and on a normal ComfyUI install they're already there. The payoff: this is the one node you can play with entirely offline, which makes it a nice first test that the pack loaded before you deal with tokens.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | text here | — |
| widthopt | INT | 512 | — |
| heightopt | INT | 512 | — |
| font_sizeopt | INT | 100 | — |
| font_nameopt | COMBO | 44 options: DejaVuSans-Bold.ttf, DejaVuSans-Bold.ttf, DejaVuSans-BoldOblique.ttf, DejaVuSans-Oblique.ttf, DejaVuSans.ttf, DejaVuSans.ttf, +38 | |
| offset_xopt | INT | 0 | — |
| offset_yopt | INT | 0 | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| text_image | IMAGE | — |
| text_image_mask | MASK | — |
| text_image_inverted | IMAGE | — |
| text_image_mask_inverted | MASK | — |