KJNodes/textgenerated

Create Text Mask(CreateTextMask)

This node creates a canvas and renders text based on the Pillow image library.

Create Text Mask

IMAGE
MASK
invert
frames
1
text_x
0
text_y
0
font_size
32
font_color
white
text
HELLO!
font
COMBO
width
512
height
512
start_rotation
0
end_rotation
0
KJNodes

The Create Text Mask node creates a canvas and renders text based on the Pillow imaging library.

The Create Text Mask node is used to generate an image containing specified text and its corresponding mask. It allows users to customize text content, font, color, position, and size, and outputs a transparent background text layer and mask that can be used in subsequent image processing workflows.

Node Functionality

This node creates a canvas and renders text based on the Pillow imaging library. It supports loading TrueType font files from a specific folder and can generate single-frame images or create multi-frame rotation animation sequences by setting start and end rotation angles. The output image and mask formats are compatible with ComfyUI's standard IMAGE and MASK data types.

Node Parameter Description - Create Text Mask

Inputs

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
fontCOMBOYes--Select the font file to use from the specified font folder.
invertBOOLEANYesFalse-Invert the mask area, swapping the mask values of the text area and the background area.
framesINTYes11 - 4096 (step: 1)Specify the number of frames for the generated image or animation.
text_xINTYes00 - 4096 (step: 1)Set the horizontal starting position (X coordinate) of the text on the canvas.
text_yINTYes00 - 4096 (step: 1)Set the vertical starting position (Y coordinate) of the text on the canvas.
font_sizeINTYes328 - 4096 (step: 1)Set the font size of the text.
font_colorSTRINGYeswhite-Set the color of the text, represented by a color name (e.g., "white") or a hexadecimal value (e.g., "#FFFFFF").
textSTRINGYesHELLO!-Input the text content to be rendered, supporting multi-line text.
widthINTYes51216 - 4096 (step: 1)Set the width of the generated image.
heightINTYes51216 - 4096 (step: 1)Set the height of the generated image.
start_rotationINTYes00 - 359 (step: 1)Set the starting rotation angle of the text (first frame only).
end_rotationINTYes0-359 - 359 (step: 1)Set the ending rotation angle of the text (last frame).

Output

Parameter NameData TypeDescription
IMAGEIMAGEOutputs the rendered text image with a transparent background.
MASKMASKOutputs the black-and-white mask corresponding to the text image.

Usage Scenarios

This node is very useful when creating text titles, adding watermarks to images, or creating workflows that require text-shaped masks for inpainting. For example, you can first generate a text mask and then connect it to a "VAE Encode" or "Image Composite" node to control the precise area for text-to-image generation or local inpainting.

Notes

Please note that font files need to be placed in the ComfyUI/custom_nodes/ComfyUI-KJNodes/fonts directory in advance for the node to recognize and load them properly. The generated image dimensions are limited by the width and height parameters, with a maximum of 4096x4096.

The Create Text Mask node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…