Nodes/ComfyUI-RMBG/Image and Mask to List (RMBG)
ComfyUI Node Runs on cloud

Image and Mask to List (RMBG)

Bundle image+mask pairs into a list

By 1038lab·Created 2 years ago·Updated 8 days ago· 2,051
Image and Mask to List (RMBG)
  • image_1
  • mask_1
  • image_2
  • mask_2
  • image_3
  • mask_3
  • image_4
  • mask_4
  • image_5
  • mask_5
  • image_6
  • mask_6
  • IMAGE
  • MASK
  • WIDTH
  • HEIGHT
  • BATCH_SIZE
resize_modecrop

Collect up to six image-and-mask pairs and hand them downstream as lists - one list of images, one list of masks - so a later node can process all of them in a loop instead of you wiring six parallel branches. If you've ever built the same six-node chain side by side because you had six inputs, this is the node that collapses that into one.

Lists are how ComfyUI does "do this to each of these." A node that takes a list runs once per item. So the pattern is: gather your pairs here into lists, feed them into whatever per-item operation you're doing (a background remover, an enhancer, a save), and it iterates automatically. This node is the gather step, and it keeps each image glued to its matching mask through the process.

How it works

You connect image/mask pairs into numbered slots - image_1 with mask_1, image_2 with mask_2, and so on up to six. It packs the images into a list and the masks into a matching list, keeping the pairing intact by index. It also optionally resizes so everything in the list shares dimensions, which downstream list operations usually need.

The inputs and outputs that matter

  • image_1image_6 and mask_1mask_6 (all optional) - the pairs. Connect as many as you have; empty slots are skipped. Keep each image with its intended mask on the same number.
  • resize_mode - off, crop, or fit. How to reconcile different-sized inputs into a uniform list. crop and fit normalize the sizes (center-crop vs. letterbox-style fit); off leaves them as-is, which only works if they're already the same size.

Outputs: IMAGE and MASK (both lists), plus WIDTH, HEIGHT, and BATCH_SIZE - the count is handy for driving downstream logic.

How to install it

  • ComfyUI Manager: search Comfyui-RMBG, install, restart.
  • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/1038lab/ComfyUI-RMBG, then pip install -r requirements.txt, and restart.

No model - pure plumbing.

Common issues

Watch the difference between a list and a batch. Some ComfyUI nodes expect a batched tensor (all images stacked into one tensor, which requires identical dimensions) and some expect a list (separate items, sizes can vary). This node outputs lists; if the node you feed wants a batch, you'll get a type or shape error, and the fix is either a list-to-batch node or setting resize_mode so everything matches and can be batched. The other snag is mismatched pairing - if you plug an image into slot 1 and its mask into slot 2, they won't line up. Keep each image and its mask on the same slot number. If you only have images and no masks, the plain Image to List node is the simpler tool.

Category🧪AILab/🖼️IMAGE

Inputs (13)

NameTypeDefaultDescription
resize_modeCOMBOcrop3 options: off, crop, fit
image_1optIMAGE
mask_1optMASK
image_2optIMAGE
mask_2optMASK
image_3optIMAGE
mask_3optMASK
image_4optIMAGE
mask_4optMASK
image_5optIMAGE
mask_5optMASK
image_6optIMAGE
mask_6optMASK

Outputs (5)

NameTypeDescription
IMAGEIMAGE
MASKMASK
WIDTHINT
HEIGHTINT
BATCH_SIZEINT