Nodes/ComfyUI_Mira/PngColor Mask to HEX String
ComfyUI Node

PngColor Mask to HEX String

One layout block, one HEX color string

By mirabarukaso·Created 2 years ago·Updated 6 days ago· 206
PngColor Mask to HEX String
  • PngColorMasks
  • mask_color
Index0

Give it the color list from a Mira PNG mask and an index, and it hands back that block's color as a HEX string - RGB(255, 0, 255) becomes #FF00FF. One region in, one hex code out. It's the string-flavored sibling of PngColorMasksToRGB, and it exists for one specific downstream consumer.

That consumer is Regional Conditioning by Color Mask (Inspire) from the Inspire Pack, which identifies regions by a hex color string rather than a mask image. If you're building a regional-prompting setup - the standard fix for two characters bleeding their attributes into each other, since a single global prompt can't keep them apart - and you've chosen the Inspire color-mask route, this is the node that translates a Mira layout block into the exact string Inspire wants.

How it works

The PngColorMasks list is a legend: each region maps to a flat RGB color. You pass an Index, the node looks up that entry and formats its three channel values into a #RRGGBB string. No pixel work, no masking - just a lookup and a format. Same idea as PngColorMasksToRGB, except the output is one ready-to-paste hex string instead of three separate integers.

The inputs that matter

Two, both required:

  • PngColorMasks - the color list from a Mira Create PNG Mask node (Tilling or Nested). The data source.
  • Index - which block, zero-based. Region 0 is the first one.

The output

A single STRING named mask_color, formatted #FF00FF. Wire it into the color input of Inspire's Regional Conditioning by Color Mask, or into anything else that accepts a hex color - some tint and fill nodes take hex directly.

Installing it

Install the whole pack. ComfyUI Manager: Manager -> Custom Nodes Manager, search ComfyUI_Mira, Install, restart. Or manually:

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

Restart. If you hit a load error, run pip install -r requirements.txt inside the ComfyUI_Mira folder and restart again. No models needed for the mask nodes.

Common issues

Index out of range is the usual mistake - it's zero-based, and it has to land on a block your layout actually contains. Off-by-one here just gives you the wrong region's color, which then quietly masks the wrong part of your image, so double-check the count.

Bigger picture: you only want this node if your regional setup is keyed on hex strings (i.e. you're on Inspire's color-mask node). If you're feeding a conditioning node that takes a MASK, don't route through strings at all - PngColorMasksToMaskList gives you finished masks directly. And if you want to read a whole range of blocks at once instead of one at a time, PngColorMasksToStringList is the batch version of this exact node.

One honest caveat on the pack: ComfyUI_Mira is a small, one-person toolbox (the author's more visible project is their WAI Character Select app), so community troubleshooting threads are sparse. When something doesn't line up, the README's regional-conditioning example is the canonical reference - it shows the Mira mask nodes wired straight into the Inspire color-mask node this output is built for.

CategoryMira/Mask

Inputs (2)

NameTypeDefaultDescription
PngColorMasksMIRA_COLOR_LIST
IndexINT0

Outputs (1)

NameTypeDescription
mask_colorSTRING