ComfyUI Node

Line

Draw a line on an image, with an honest coordinate system

By lucafoscili·Created 2 years ago·Updated 2 years ago· 50
Line
  • image
  • ui_widget
  • image
  • image_list
start_x0.50
start_y0.00
end_x0.50
end_y1.00
size10
colorFF0000
opacity1.00
smoothfalse
mid_x0.25
mid_y0.25

Every now and then a workflow needs to put a line on an image - a guideline for an editor, an annotation for a review pass, a composition ruler. LF_Line does exactly one thing and does it well: draw a line between two points in normalized coordinates, with control over thickness, color, opacity, and smoothness.

The normalized coordinate system is the detail that makes this node pleasant. Instead of pixels, you get positions as values between 0 and 1 - start_x 0 is the left edge, 1 is the right edge, same for start_y top to bottom. That means the same workflow draws a centered vertical line whether your image is 512×512 or 2K, with no resolution math in your head. The defaults already draw a vertical line down the middle (start_x 0.5, start_y 0 → end_x 0.5, end_y 1), which is a decent starting point to tweak.

How it works

The required inputs are the geometry and the styling. start_x, start_y, end_x, end_y define the line in that 0–1 space. size (1–500, default 10) is the line diameter in pixels - yes, diameter, the tooltip says so, so it reads as thickness. color is a hex string (default FF0000, red). opacity (0–1) fades the line in. smooth (boolean) switches from a hard-edged line to an antialiased one, which you want when the line is part of a final image rather than a rough guide.

There's also an optional mid_x / mid_y pair - a control point that bends the line into a curve when smooth is on. With straight lines it's irrelevant; with smooth on, it turns the node into a simple curve drawer.

Outputs are image and image_list, same as the other filters in this pack, so it composes with the rest of your chain.

Installing it

Part of LF Nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/lucafoscili/comfyui-lf

Restart, or use ComfyUI Manager and search LF Nodes. No models, no downloads beyond the pack's light dependencies (numpy, Pillow, opencv-python).

Gotchas

The coordinate system trips people up once. Because everything is normalized 0–1, a start_x of 0.5 really is the horizontal middle regardless of aspect ratio - but remember Y runs top to bottom, so start_y 0 is the top edge. Getting a line "upside down" is almost always this.

And when the line looks jagged, it's the smooth toggle, not a bug. Hard edges are the default; flip smooth on for anything that's going into a final render.

Pack note: comfyui-lf is legacy, frozen Feb 2025, and the author's active development moved to lucafoscili/lf-nodes. The frozen build here works fine and the compare preview is already the best part.

Category✨ LF Nodes/Filters

Inputs (12)

NameTypeDefaultDescription
imageIMAGEInput image tensor to draw a line upon.
start_xFLOAT0.500–1Horizontal position to begin the line drawing, expressed as a value between 0 and 1.
start_yFLOAT0.000–1Vertical position to begin the line drawing, expressed as a value between 0 and 1.
end_xFLOAT0.500–1Horizontal position to end the line drawing, expressed as a value between 0 and 1.
end_yFLOAT1.000–1Vertical position to end the line drawing, expressed as a value between 0 and 1.
sizeINT101–500Diameter of the line in pixels.
colorSTRINGFF0000Hex color of the line.
opacityFLOAT1.000–1Opacity of the line.
smoothBOOLEANfalseDraws a smooth line.
mid_xoptFLOAT0.250–1Horizontal midpoint of the line, expressed as a value between 0 and 1.
mid_yoptFLOAT0.250–1Vertical midpoint of the line, expressed as a value between 0 and 1.
ui_widgetoptKUL_COMPARE[object Object]

Outputs (2)

NameTypeDescription
imageIMAGE
image_listIMAGE