Masks From Color Swatches
Turn a flat-color region map into one mask per zone
- image_color_mask
- color_swatches
- masks
RES4LYF's headline feature list includes regional conditioning with "unlimited zones," and its README is explicit that you can build those zones either by drawing freely or with "more traditional rigid ones" - meaning a flat, block-colored region map. Masks From Color Swatches is the tool that turns the second kind into usable masks: paint your image into solid-color regions, define a swatch per color, and this node hands you back one mask per swatch, as a list.
If you've ever done rigid multi-region compositing work - the kind where you paint a simple color-coded layout image before feeding it into a mask pipeline - this is the exact pattern RES4LYF built for.
How it works
You give it two things: image_color_mask, the flat-color reference image where each region is painted a distinct solid color, and color_swatches, the set of colors you want extracted as separate masks. For each swatch, the node isolates the pixels matching that color and turns them into a mask, returning all of them together - the node's own description says explicitly that it "returns them as a list."
The inputs and outputs that matter
image_color_mask(required) - your flat-color region map. Solid, distinct colors per zone make this reliable; anti-aliased or gradient edges will blur the boundary between regions.color_swatches(required,COLOR_SWATCHES) - the set of colors to extract, picked to match the colors you painted.- Output:
masks- a list of masks, one per swatch, in swatch order.
Because the output is a list rather than individually-wired sockets, most workflows pair this node with Masks-Unpack-4, Masks-Unpack-8, or Masks-Unpack-16 right after it, splitting the list back into separate mask outputs you can wire into individual conditioning zones.
How to install it
Via ComfyUI Manager: search "RES4LYF" and install. Manually, from ComfyUI/custom_nodes:
git clone https://github.com/ClownsharkBatwing/RES4LYF/
cd RES4LYF
pip install -r requirements.txt
Activate your venv first if you use one; on portable installs, use python_embedded\Scripts\pip.exe in place of pip. Restart ComfyUI once installed.
Common issues & troubleshooting
Regions bleed into each other or masks come out wrong at the edges. This node is matching on color, so anti-aliasing, JPEG compression artifacts, or soft brush edges on your image_color_mask will produce fuzzy or overlapping boundaries. Paint with a hard-edged brush and export as PNG, not a lossy format, to keep the colors clean.
A swatch produces an empty mask. The swatch color needs to match what's actually in the image pixel-for-pixel (or close enough for the node's matching tolerance). If you picked a swatch color by eye rather than sampling it directly from the painted image, small differences can mean zero matching pixels.
Downstream nodes only see the first mask, or reject the input entirely. That's the list output - the same landmine as any list-producing node in ComfyUI. Route through Masks-Unpack-4/8/16 to split it into individual mask sockets before wiring into nodes that expect a single MASK.
You'd rather draw your zones by hand than paint flat colors. Mask-Sketch is the freehand counterpart described in the same part of RES4LYF's README - reach for that instead if a rigid color-coded map isn't the right fit for your image.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image_color_mask | IMAGE | — | |
| color_swatches | COLOR_SWATCHES | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| masks | MASK | — |