Add Label(AddLabel)
From a technical implementation perspective, this node uses the PIL library for image processing and text rendering.
Add Label
From a technical implementation perspective, the Add Label node utilizes the PIL library for image processing and text rendering.
The Add Label node is an image annotation tool that adds a label strip containing custom text onto an input image. Its core functionality is to generate a background area with text and then stitch or overlay it onto the original image, thereby adding descriptive text to the image.
Node Functionality
From a technical implementation perspective, this node uses the PIL library for image processing and text rendering. It supports stitching the label strip to the "top, bottom, left, or right" edges of the image, or overlaying it directly onto the image in "overlay" mode. The node loads font files from a specified font folder (typically ComfyUI/custom_nodes/ComfyUI-KJNodes/fonts) and allows users to define the text and label background colors using color strings (e.g., "white", "#FF0000").
Node Parameter Description - Add Label
Connection Inputs (Inputs)
| Parameter Name | Data Type | Required | Default Value | Value Range/Options | Description |
|---|---|---|---|---|---|
image | IMAGE | Yes | - | - | image (Input Parameter): The original image to which the label needs to be added. |
font | COMBO | Yes | - | (List of available fonts) | font (Input Parameter): Select the font file used for rendering the text. The font file must be placed in the specified kjnodes_fonts directory. |
Control Parameters (Parameters)
| Parameter Name | Data Type | Required | Default Value | Value Range/Options | Description |
|---|---|---|---|---|---|
direction | COMBO | Yes | up | "up", "down", "left", "right", "overlay" | down (bottom), left (left side), right (right side), or overlay (directly overlaid on the image). |
text_x | INT | Yes | 10 | 0 - 4096 (Step: 1) | text_x (Input Parameter): Sets the horizontal starting position (X coordinate) of the label text within the label strip. Value range is 0 to 4096. |
text_y | INT | Yes | 2 | 0 - 4096 (Step: 1) | text_y (Input Parameter): Sets the vertical starting position (Y coordinate) of the label text within the label strip. Value range is 0 to 4096. |
height | INT | Yes | 48 | -1 - 4096 (Step: 1) | height (Input Parameter): Sets the height of the label strip (when the direction is left or right, this parameter controls the width). When the value is -1, the height will automatically adapt to the font size. |
font_size | INT | Yes | 32 | 0 - 4096 (Step: 1) | font_size (Input Parameter): Sets the font size of the label text. Value range is 0 to 4096. |
font_color | STRING | Yes | white | - | font_color (Input Parameter): Defines the color of the label text. Supports color names (e.g., "white") or hexadecimal color codes (e.g., "#FF0000"). |
label_color | STRING | Yes | black | - | label_color (Input Parameter): Defines the background color of the label strip. Supports color names (e.g., "black") or hexadecimal color codes. |
text | STRING | Yes | Text | - | text (Input Parameter): Input the text content to be displayed on the label strip. |
caption | STRING | No | "" | - | caption (Input Parameter): Optional additional caption text. |
Output
| Parameter Name | Data Type | Description |
|---|---|---|
| IMAGE | IMAGE | IMAGE (Output Parameter): Outputs the image with the text label added. |
Usage Scenarios
This node is very practical in image batch processing or generation workflows. For example, after generating a series of style test images, you can use this node to automatically add a label to each image describing its parameters (such as model name, sampling steps), facilitating subsequent comparison and filtering. It can also be used to add dialogue text or sequence numbers to comic panels or storyboard images.
Notes
It is important to note that when selecting the "top, bottom, left, right" directions, this operation will change the dimensions (height or width) of the output image. Additionally, font color and label background color support various formats, but it is necessary to ensure that the input string can be correctly parsed as an RGB color value.
Add Label Node Source Code Link
The Add Label node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.