ComfyUI-Rect

ComfyUI-Rect
★ 3

交互式选择裁剪遮罩处理填充/描边
在ComfyUI中提供交互式矩形选择工具,可绘制与微调框并输出标准RECT(x/y/w/h),用于裁剪、生成羽化/反转/合并遮罩及填充/描边,兼容批处理与GPU/CPU。
💡 在图像上交互式选区以裁剪、遮罩或标注。
🍴 2 Forks💻 Python🔄 2025-08-24
📦
网盘下载
复制链接后前往夸克网盘下载
https://pan.quark.cn/s/e00a65475347
Rect / Select overlay
Example workflow
📄 README

ComfyUI-Rect

Interactive rectangle tools for ComfyUI.

Includes an interactive Rect / Select (marching-ants popup) plus Rect / Crop, Rect / Mask, and Rect / Fill.

Outputs a reusable RECT object ({x,y,w,h}) and the four scalar values for compatibility with existing nodes.


Screenshots

Example Workflow

Load this workflow:

assets/demo-workflow.json

Features

  • 🖱️ Interactive selector: draw/refine a box over your input image
  • 🧱 Clean RECT type + x/y/w/h ints
  • ✂️ Crop, 🧪 Mask (feather/invert/combine), 🟩 Fill/Outline (color + opacity)
  • Bounds-safe, batch-safe, GPU/CPU friendly
  • Modular pack layout (easy to extend)

  • Install

  • Copy the folder ComfyUI-Rect into:
  • “`

    ComfyUI/custom_nodes/

    “`

  • Restart ComfyUI.
  • If the “Open Rect / Select” button doesn’t appear, it’s almost always cache—use ?nocache=1.


    Nodes

    Rect / Select

    Inputs

  • image: IMAGE (required)
  • Outputs

  • rect: RECT (object with x,y,w,h)
  • x: INT, y: INT, w: INT, h: INT
  • UI

  • Button Open Rect / Select opens an overlay where you drag a rectangle over the input image. Values sync back to the node.
  • Rect / Crop

  • Inputs: image: IMAGE, rect: RECT
  • Output: image: IMAGE (cropped)
  • Rect / Mask

  • Inputs: image: IMAGE, rect: RECT
  • Options: feather (px), invert, combine (replace/union/intersect/subtract/multiply)
  • Optional: existing_mask: MASK
  • Output: mask: MASK (0..1)
  • Rect / Fill

  • Inputs: image: IMAGE, rect: RECT
  • Color: r,g,b (0–255), opacity (0..1)
  • Mode: fill or outline, thickness (outline), feather
  • Output: image: IMAGE (blended)

  • Quickstart

  • Load ImageRect / Select (click *Open Rect / Select*, draw a box)
  • Feed rect to:
  • Rect / Crop → get a cropped image, or
  • Rect / Mask → build a mask (then drive any mask-aware node), or
  • Rect / Fill → draw a solid block or outline for redactions/callouts.

  • RECT type

    A simple JSON-like object:

    {"x": 100, "y": 80, "w": 256, "h": 256}

    All coordinates are in image pixel space. Values are clamped to the image bounds for safety.


    Troubleshooting

  • Button missing (“Open Rect / Select”) → open with ?nocache=1.
  • No image in selector → ensure the node’s image input is connected.
  • JS not loading → verify the folder path is exactly ComfyUI/custom_nodes/ComfyUI-Rect/ and restart ComfyUI.

  • Roadmap

  • Rect / Transform (offset/expand/scale-around-center)
  • Helper: Mask → Rect (BBox) (in companion *MaskTools* pack)

  • License

    MIT