KJNodes/masking/generategenerated

Create Text On Path(CreateTextOnPath)

This node receives a JSON string containing a list of coordinate points to define the baseline path of the text.

Create Text On Path

image
mask
mask_inverted
coordinates
STRING
text
text
frame_width
512
frame_height
512
font
COMBO
font_size
42
alignment
center
text_color
white
size_multiplier
1
KJNodes

The Create Text On Path node creates a mask or batch of masks with the specified text. Locations are center locations.

The Create Text On Path node is used to generate text at specified positions on an image, outputting the image containing the text, a text mask, and its inverted mask. It allows users to define the center locations for each text instance via coordinate points, enabling the creation of text effects that are arranged at arbitrary positions.

Node Functionality

This node receives a JSON string containing a list of coordinate points to define the center locations for each text instance. It uses the Pillow library to render text on a canvas of specified dimensions, supports loading custom fonts from a dropdown list of available fonts, and can process batch coordinate inputs to generate multiple text images and masks. Its core functionality is to convert text color into grayscale values for the mask and generate the corresponding inverted mask.

Node Parameter Description - Create Text On Path

Connection Inputs (Inputs)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
fontCOMBOYes--The font file used to render the text, selected from the available fonts.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
alignmentCOMBOYescenter"left", "center", "right"Determines the horizontal alignment of the text relative to the given coordinate point.
coordinatesSTRINGYes--A list of coordinate points defining the center locations for each text instance. Must be a correctly formatted JSON string, e.g., "[[x1, y1], [x2, y2]]".
textSTRINGYestext-The text content to be rendered onto the image, supports multi-line input.
frame_widthINTYes51216 - 4096 (Step: 1)The width of the output image, ranging from 16 to 4096 with a step of 1.
frame_heightINTYes51216 - 4096 (Step: 1)The height of the output image, ranging from 16 to 4096 with a step of 1.
font_sizeINTYes42-The font size for rendering the text, in pixels.
text_colorSTRINGYeswhite-The color of the text, supports color names (e.g., "white") or hexadecimal codes (e.g., "#FFFFFF").
size_multiplierFLOATNo[1]-Optional multiplier for the text size; when provided, the length of its list should match the coordinate batch size or be broadcastable.

Output

Parameter NameData TypeDescription
imageIMAGEThe RGB image with the text.
maskMASKA grayscale mask of the text area, where white represents the text.
mask_invertedMASKThe inverted mask of the text area, where black represents the text.

Usage Scenarios

When creating dynamic text titles or watermarks, the mask generated by this node can be connected to nodes like VAE Encode or Set Latent Noise Mask to control the area for image generation or editing. For example, you can use this node to generate a mask for text placed at specific positions, then use this mask to guide the AI to draw an image within that shape.

Notes

The input coordinates parameter must be a correctly formatted JSON string, e.g., "[[100, 200], [150, 180], [200, 200]]". size_multiplier is an optional parameter; when provided, the length of its list should match the coordinate batch size or be broadcastable.

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

Comments

Sign in with GitHub to join the discussion.

Loading comments…