Nodes/ComfyUI_Mira/PngColor Mask to INT RGB
ComfyUI Node

PngColor Mask to INT RGB

Pull the R, G, B out of one layout block

By mirabarukaso·Created 2 years ago·Updated 5 days ago· 206
PngColor Mask to INT RGB
  • PngColorMasks
  • R
  • G
  • B
Index0

Small, single-purpose node: give it the color list from a Mira PNG mask and a block index, and it spits out three integers - the red, green, and blue of that block. That's it. It exists so other nodes that identify a region by its color value (rather than by a mask image) can be fed cleanly.

To understand why anyone needs this, back up to what the Mira mask nodes are for. Regional prompting splits the canvas into areas so two characters stop swapping hair colors - the classic attribute-bleed problem that a single global prompt can't solve. The Create PNG Mask nodes draw those areas as flat color blocks and emit a PngColorMasks list describing them. Some downstream nodes want the region as a mask; others want the raw color that identifies it. This node serves the second camp.

How it works

The color list is basically a legend - region 0 is this RGB, region 1 is that RGB, and so on. You pass in an Index, the node looks up that entry, and returns its three channel values as separate INT outputs. RGB(255, 0, 255) comes out as R=255, G=0, B=255. No image processing, no math beyond a lookup.

The inputs that matter

There are only two, and both are required:

  • PngColorMasks - the color list from a Mira Create PNG Mask node. This is the whole data source.
  • Index - which block you want, counting from 0. Want the color of the third region? Set Index to 2.

The outputs

Three integers: R, G, B. The intended target is a node like ComfyUI's Mask From Color (the 🔧 wrench one), which takes an image plus an RGB triple and builds a mask from every pixel matching that color. So the pattern is: this node reads which color region 2 is, and Mask From Color turns that color into a usable mask. You can also feed the values into any node that takes numeric RGB inputs - solid-color image generators, tint nodes, debugging.

Installing it

Grab the whole pack, not just this node. Easiest is ComfyUI Manager: Manager -> Custom Nodes Manager, search ComfyUI_Mira, Install, restart. Or clone it:

cd ComfyUI/custom_nodes
git clone https://github.com/mirabarukaso/ComfyUI_Mira.git

Restart afterward. If nodes fail to load, run pip install -r requirements.txt in the ComfyUI_Mira directory and restart. Nothing to download beyond the code.

Common issues

The main way to trip up is the Index. It's zero-based, and it has to point at a region that actually exists in your layout - ask for index 8 in a four-block layout and you're reaching past the end. If the output looks wrong, count your blocks and remember the first one is 0, not 1.

The other thing worth saying plainly: this is a plumbing node inside a plumbing chain. It's genuinely useful only when you're driving a color-keyed masking node downstream. If your conditioning node takes a MASK directly, skip this entirely and use PngColorMasksToMaskList instead - it hands you finished masks and saves you the color-to-mask round trip.

Finally, ComfyUI_Mira is a niche solo pack (the author is better known for their WAI Character Select tool), so there's not much of a forum trail if you get stuck. The README's regional-conditioning walkthrough is the reference to lean on, and it shows exactly which downstream nodes these color values are meant to feed.

CategoryMira/Mask

Inputs (2)

NameTypeDefaultDescription
PngColorMasksMIRA_MASKS_LIST
IndexINT0

Outputs (3)

NameTypeDescription
RINT
GINT
BINT