KJNodes/imagegenerated

Cut And Drag On Path(CutAndDragOnPath)

The node first parses the input path coordinate string, then precisely identifies the boundaries of the image area covered by the mask and crops it out.

Cut And Drag On Path

image
mask
bg_image
image
mask
coordinates
STRING
frame_width
512
frame_height
512
inpaint
KJNodes

The Cut And Drag On Path node first parses the input path coordinate string, then precisely identifies the boundary of the image area covered by the mask and crops it out.

The Cut And Drag On Path node is an image processing tool that cuts out the area selected by a mask from an image and moves it along a user-defined path. This node is primarily used to create dynamic effects, such as making an object slide or float along a specific trajectory within the frame. If the inpainting feature is enabled, it can also intelligently fill the gaps left by the cut-out area.

Node Functionality

The node first parses the input path coordinate string, then precisely identifies the boundary of the image area covered by the mask and crops it out. The cropped image fragment is then displaced and composited onto a canvas of the specified dimensions according to the coordinate sequence. The technical core lies in coordinate parsing, region cropping, and position remapping. It supports standard IMAGE and MASK tensor formats and optionally uses a background image or a built-in inpainting algorithm to handle the background.

Node Parameter Description - Cut And Drag On Path

Connection Inputs (Inputs)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
imageIMAGEYes--The input image from which the masked area will be cut out and moved along the path.
maskMASKYes--The mask that defines the region to be cut from the image. Only non‑zero pixels are considered.
bg_imageIMAGENo--Optional background image. If provided, this image will be used to fill blank areas instead of the inpainting algorithm.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
coordinatesSTRINGYes--A string defining the coordinate sequence for the movement path. Must be a JSON array in a specific format.
frame_widthINTYes51216 - 4096 (Step: 1)Sets the width of the output image. Valid range is 16 to 4096, with a step of 1.
frame_heightINTYes51216 - 4096 (Step: 1)Sets the height of the output image. Valid range is 16 to 4096, with a step of 1.
inpaintBOOLEANYesTrue-Boolean switch controlling whether to perform intelligent inpainting to fill the blank areas left after cutting. When enabled and no background image is provided, the cut area is filled using the cv2 TELEA algorithm.

Output

Parameter NameData TypeDescription
imageIMAGEThe processed output image sequence.
maskMASKThe mask sequence transformed along the same path.

Usage Scenarios

You can use this node when creating simple animations or special effects. For example, in a video frame processing workflow, you can first obtain an object's mask using SAM or manual drawing, then generate a motion path coordinate sequence through other nodes, and finally connect it to this node. This will output a series of image sequences showing the object moving along the path, ready for subsequent frame composition.

Notes

Please note that the input coordinate string must conform to specific JSON format requirements; otherwise, it may not be parsed correctly. Additionally, if the mask area is completely black (i.e., no area is selected), the node will directly return the original input without any processing.

The Cut And Drag On Path node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…