Nodes/ComfyUI-ZoeyTool/🎨 Zoey - 遮罩边界框绘制
ComfyUI Node

🎨 Zoey - 遮罩边界框绘制

From a mask to a colored bounding box with a light position prompt — plus rembg when you need it

By liangzoey·Created about a year ago·Updated 3 days ago· 5
🎨 Zoey - 遮罩边界框绘制
  • 图像
  • 遮罩
  • 自定义颜色
  • 主体遮罩
  • 图像
  • 位置提示词
线宽2
填充
强度1.00
启用预设颜色true
预设颜色红色
边距百分比5.0
灯光后置false
光照类型摄影棚灯光

ZoeyMaskDrawBox turns a mask into a drawn bounding box with an HTML-color-picker polish that feels like a mini design tool. Feed it an image and a mask - from a segmentation pass, an object detector, whatever - and it finds the mask's bounding rectangle, draws a box around it on the image (line or translucent fill, your color, your line width, with a margin), and then does the clever part: it writes you a position prompt describing that region as a light source. Draw the box, get a sentence you can paste into a relight/edit prompt that says exactly where the light should be. That two-for-one is the whole reason this node exists.

It's from comfyui-ZoeyTool, part of the pack's image-editing family that pairs visual masks with light-position prompting (its sibling ZoeyLightHandle does the same idea interactively with a draggable handle). These fit into IC-Light-style relighting or region-edit workflows where you know where the subject is but a model still needs to be told in words.

How it works

Required inputs are 图像 (image), 遮罩 (mask), and 线宽 (line width). The node computes the mask's bounding rectangle with an adjustable 边距百分比 margin (default 5%), then draws on the image: with 填充 = 是 it fills the box with a translucent tint, otherwise just an outline. Color comes from 启用预设颜色 + one of 11 预设颜色 names, or you can switch presets off and use the 自定义颜色 COLOR picker directly. 强度 scales the opacity.

Two options take it further:

  • 光照类型 - pick from 16 light types (studio, god rays/丁达尔光, hard/soft, rim, backlight, window-blind stripes, etc.), and the generated prompt embeds that type's natural-language description instead of a generic "light here."
  • 灯光后置 ("light behind subject") - when on, the drawn box stays behind the subject instead of covering it. It needs a 主体遮罩 (subject mask) to know what the subject is; if you don't provide one it will happily auto-run rembg to cut the subject out itself (first use downloads the rembg model). The composite ends with the subject intact above your colored box.

Outputs are the annotated 图像 and the 位置提示词 string - the latter is what you wire into a prompt field or copy out.

Installing it

Pack install as always:

cd ComfyUI/custom_nodes
git clone https://github.com/liangzoey/comfyui-ZoeyTool.git
cd comfyui-ZoeyTool
pip install -r requirements.txt

Restart ComfyUI (or ComfyUI Manager → comfyui-ZoeyTool). Caveat: the pack's actual requirements.txt installs rembg unconditionally, which drags in onnxruntime and a chunky model download on first background-removal use. If you never use 灯光后置 without a subject mask, rembg sits there unused - harmless, just disk.

Where people get burned

The mask-expectation mismatch is the #1 beginner trip: the node needs a real mask tensor, not "an image with the background transparent." If you wire in an RGBA image expecting alpha to be read, you'll get either an error or a nonsense bbox. Feed it an actual MASK output from a segmentation/grounding node. Second, the color opacity math means thin lines at low 强度 can look nearly invisible on bright images - bump line width or intensity. And the position prompt is in Chinese by design (matching the pack's other light nodes) - if you're pasting into an English-only prompt pipeline you'll be translating a sentence, which is a real friction point to know about up front rather than discover at output time.

CategoryZoey工具集/图像编辑

Inputs (12)

NameTypeDefaultDescription
图像IMAGE
遮罩MASK
线宽INT21–20
填充optCOMBO2 options: 否, 是
强度optFLOAT1.000–1
启用预设颜色optBOOLEANtrue
预设颜色optCOMBO红色11 options: 红色, 橙色, 黄色, 绿色, 青色, 蓝色, +5
自定义颜色optCOLOR#ff0000
边距百分比optFLOAT5.00–50
灯光后置optBOOLEANfalse
光照类型optCOMBO摄影棚灯光16 options: 摄影棚灯光, 丁达尔光, 光斑, 束光, 栅栏光, 散射光, +10
主体遮罩optMASK

Outputs (2)

NameTypeDescription
图像IMAGE
位置提示词STRING