Skip to content

ImageDrawLineByContainer

Documentation

  • Class name: ImageDrawLineByContainer
  • Category: image/draw
  • Output node: False

The ImageDrawLineByContainer node is designed to draw lines on images by specifying the start and end points, color, and other drawing parameters. It abstracts the complexity of image manipulation, allowing for easy integration of line drawing capabilities into image processing workflows.

Input types

Required

  • container
    • The container parameter represents the image data on which the line will be drawn. It is crucial for determining the dimensions and the canvas for the line drawing.
    • Comfy dtype: IMAGE
    • Python dtype: numpy.ndarray
  • size
    • Specifies the thickness of the line to be drawn on the image.
    • Comfy dtype: INT
    • Python dtype: int
  • start_x
    • The starting x-coordinate for the line.
    • Comfy dtype: FLOAT
    • Python dtype: int
  • start_y
    • The starting y-coordinate for the line.
    • Comfy dtype: FLOAT
    • Python dtype: int
  • end_x
    • The ending x-coordinate for the line.
    • Comfy dtype: FLOAT
    • Python dtype: int
  • end_y
    • The ending y-coordinate for the line.
    • Comfy dtype: FLOAT
    • Python dtype: int
  • red
    • The red component of the color of the line.
    • Comfy dtype: INT
    • Python dtype: int
  • green
    • The green component of the color of the line.
    • Comfy dtype: INT
    • Python dtype: int
  • blue
    • The blue component of the color of the line.
    • Comfy dtype: INT
    • Python dtype: int
  • alpha
    • The alpha (transparency) component of the color of the line.
    • Comfy dtype: FLOAT
    • Python dtype: int
  • SSAA
    • Specifies the Super Sampling Anti-Aliasing factor to improve the quality of the line drawing.
    • Comfy dtype: INT
    • Python dtype: int
  • method
    • Determines the drawing method or algorithm used for line rendering.
    • Comfy dtype: COMBO[STRING]
    • Python dtype: str

Output types

  • image
    • Comfy dtype: IMAGE
    • The output is an image with the specified line drawn on it.
    • Python dtype: numpy.ndarray

Usage tips

  • Infra type: CPU
  • Common nodes: unknown

Source code

class ImageDrawLineByContainer:
    def __init__(self):
        pass

    @classmethod
    def INPUT_TYPES(cls):
        return {
            "required": {
                "container": ("IMAGE",),
                "size": ("INT", {
                    "default": 1,
                    "min": 1,
                    "step": 1
                }),
                "start_x": ("FLOAT", {
                    "default": 0.0,
                    "max": 1.0,
                    "step": 0.01
                }),
                "start_y": ("FLOAT", {
                    "default": 0.0,
                    "max": 1.0,
                    "step": 0.01
                }),
                "end_x": ("FLOAT", {
                    "default": 1.0,
                    "max": 1.0,
                    "step": 0.01
                }),
                "end_y": ("FLOAT", {
                    "default": 1.0,
                    "max": 1.0,
                    "step": 0.01
                }),
                "red": ("INT", {
                    "default": 255,
                    "max": 255,
                    "step": 1
                }),
                "green": ("INT", {
                    "default": 255,
                    "max": 255,
                    "step": 1
                }),
                "blue": ("INT", {
                    "default": 255,
                    "max": 255,
                    "step": 1
                }),
                "alpha": ("FLOAT", {
                    "default": 1.0,
                    "max": 1.0,
                    "step": 0.01
                }),
                "SSAA": ("INT", {
                    "default": 4,
                    "min": 1,
                    "max": 16,
                    "step": 1
                }),
                "method": (["lanczos", "bicubic", "hamming", "bilinear", "box", "nearest"],),
            },
        }

    RETURN_TYPES = ("IMAGE",)
    FUNCTION = "node"
    CATEGORY = "image/draw"

    # noinspection PyPep8Naming
    def node(self, container, size, start_x, start_y, end_x, end_y, red, green, blue, alpha, SSAA, method):
        return ImageDrawLine().node(
            container[0, :, :, 0].shape[1],
            container[0, :, :, 0].shape[0],
            size,
            start_x,
            start_y,
            end_x,
            end_y,
            red,
            green,
            blue,
            alpha,
            SSAA,
            method
        )