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
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 Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
image | IMAGE | Yes | - | - | The input image from which the masked area will be cut out and moved along the path. |
mask | MASK | Yes | - | - | The mask that defines the region to be cut from the image. Only non‑zero pixels are considered. |
bg_image | IMAGE | No | - | - | Optional background image. If provided, this image will be used to fill blank areas instead of the inpainting algorithm. |
Control Parameters (Parameters)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
coordinates | STRING | Yes | - | - | A string defining the coordinate sequence for the movement path. Must be a JSON array in a specific format. |
frame_width | INT | Yes | 512 | 16 - 4096 (Step: 1) | Sets the width of the output image. Valid range is 16 to 4096, with a step of 1. |
frame_height | INT | Yes | 512 | 16 - 4096 (Step: 1) | Sets the height of the output image. Valid range is 16 to 4096, with a step of 1. |
inpaint | BOOLEAN | Yes | True | - | 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 Name | Data Type | Description |
|---|---|---|
| image | IMAGE | The processed output image sequence. |
| mask | MASK | The 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.
Cut And Drag On Path Node Source Code Link
The Cut And Drag On Path node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.