Image and Mask to List (RMBG)
Bundle image+mask pairs into a list
- 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
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_1…image_6andmask_1…mask_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, orfit. How to reconcile different-sized inputs into a uniform list.cropandfitnormalize the sizes (center-crop vs. letterbox-style fit);offleaves 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, thenpip 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.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| resize_mode | COMBO | crop | 3 options: off, crop, fit |
| image_1opt | IMAGE | — | |
| mask_1opt | MASK | — | |
| image_2opt | IMAGE | — | |
| mask_2opt | MASK | — | |
| image_3opt | IMAGE | — | |
| mask_3opt | MASK | — | |
| image_4opt | IMAGE | — | |
| mask_4opt | MASK | — | |
| image_5opt | IMAGE | — | |
| mask_5opt | MASK | — | |
| image_6opt | IMAGE | — | |
| mask_6opt | MASK | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |
| WIDTH | INT | — |
| HEIGHT | INT | — |
| BATCH_SIZE | INT | — |