Nodes/ComfyUI-Apt_Preset/Image_Channel_Apply
ComfyUI Node

Image_Channel_Apply

Read or write a single RGBA channel as a mask

By cardenluo·Created 2 years ago·Updated 18 days ago· 309
Image_Channel_Apply
  • images
  • channel_data
  • image
  • mask
channel
invert_channelfalse
background_colornone

ComfyUI's IMAGE tensor is RGB - there's no alpha riding along by default, even after a background-removal node hands you a nice clean mask. If you need that mask actually baked into an alpha channel for a transparent PNG export, or you want to pull one specific channel out of an image to inspect or reuse elsewhere, Image_Channel_Apply is the plumbing node that does it in either direction.

How it works

Pick a channel - R, G, B, or A. Leave channel_data disconnected and the node reads that channel back out of images as a mask output. Wire a MASK into channel_data and it does the opposite: writes that mask into the channel you picked, replacing whatever was there. invert_channel flips the values either way. background_color (default "none", with ten flat-color options plus "image") exists mainly so you can actually see what you're doing - raw alpha or a single extracted channel doesn't render usefully in most previews, so this composites the result onto a solid backdrop for the image output specifically.

The inputs and outputs that matter

  • images (required) and channel (required, R/G/B/A) - what you're reading from or writing to.
  • channel_data (optional, MASK) - supply this to write a mask into the chosen channel; leave it empty to read the channel out instead.
  • invert_channel (default false) - flips the channel values in either direction.
  • background_color (default "none") - a flat backdrop for previewing, since raw channel/alpha data alone is hard to read.
  • Output: image, mask.

How to install it

Via ComfyUI Manager: search ComfyUI-Apt_Preset, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git

Windows: double-click install.bat. Linux/Mac: pip install -r ComfyUI-Apt_Preset/requirements.txt in your venv - there's no equivalent script for non-Windows. Restart. This node is plain channel math, nothing to download; the pack's broader dependency list (pandas, gguf, onnxruntime, and friends) is for other corners of Apt_Preset, a fairly large, actively maintained pack sitting around 300 GitHub stars.

Common issues & troubleshooting

Expecting alpha that isn't there. Most LoadImage-style nodes in ComfyUI only carry RGB unless the source file genuinely had transparency and the loader preserved it. Image_Channel_Apply can only read a channel that exists - it can't invent alpha out of nothing. If you want transparency, build it: run a background-removal node to get a mask, then write that mask into the A channel with channel_data.

Result looks black or invisible. If you're inspecting a freshly-zeroed or newly-written channel, background_color set to "none" may just show as black or transparent in a viewer that doesn't render alpha properly. Switch it to a visible flat color to sanity-check what you actually wrote.

Writing instead of reading, by accident. The direction is decided entirely by whether channel_data is wired - an accidental connection there will overwrite the channel you meant to just inspect. Disconnect it if you only want a read.

Node missing from the menu. Apt_Preset registers from one Python module, so a broken dependency anywhere in requirements.txt can hide the whole pack, not just this node - check the console for import errors before assuming this node specifically is at fault.

CategoryApt_Preset/image/color_adjust

Inputs (5)

NameTypeDefaultDescription
imagesIMAGE
channelCOMBO4 options: A, R, G, B
invert_channelBOOLEANfalse
channel_dataoptMASK
background_coloroptCOMBOnone11 options: none, image, white, black, red, green, +5

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK