ImageHasAlpha
Does your image actually have transparency? This tiny node asks
- image
- has_alpha
ImageHasAlpha is the smallest node in the WBLESS pack, and the one that answers a question you'll eventually hit: does this image tensor actually carry transparency? One input, one boolean output, nothing else. It's the sort of thing you don't need until the moment you're building a workflow that must handle both cutouts and opaque images - and then it's exactly what you were missing.
Here's the setup where it earns its keep. You're compositing: some branch of your graph produces a transparent foreground (say, from a matting model or the pack's own ApplyMaskToAlpha), another branch produces a plain opaque image. Rather than guessing which one you're holding, you run ImageHasAlpha and feed its has_alpha boolean into a Switch to pick the right branch. Same trick works for routing images into background-removal vs. skipping it, or deciding whether a PNG needs compositing onto a canvas at all. In a pack full of alpha-aware nodes - ApplyMaskToAlpha, Image Mask Blend, Area Based Scale (Pixel) - it's the sanity check that ties them together.
How it works
The mechanism is delightfully blunt. ComfyUI represents images as tensors of shape [batch, height, width, channels]. ImageHasAlpha checks the channel count: 4 means RGBA, 3 means RGB, and it returns True or False accordingly. But it doesn't stop there - an RGBA image where every alpha value is literally 1.0 has no actual transparency, so the node checks the alpha channel for any pixel below 1.0 (with a tiny 1e-6 tolerance for float noise) before declaring victory. A 4-channel image that's secretly opaque reports False. That's a nice touch of honesty. It also processes a batch by testing only the first image, and it disables ComfyUI's caching so it re-checks every run.
The gotcha that will trip you up
Here's the thing nobody tells you: ComfyUI's standard LoadImage converts everything to RGB and silently drops the alpha channel. Load a PNG that "has transparency" the normal way and this node returns False - the transparency was already gone before the node ever saw it. So ImageHasAlpha is genuinely useful for images that carry RGBA inside the graph (outputs of matting nodes, ApplyMaskToAlpha, LayerDiffusion-style generation), not for PNGs you loaded from disk expecting a reveal. If you need to know whether the file has alpha, you want a node that inspects the file, not the tensor.
Wiring it up
- Input
image- any IMAGE. That's it. - Output
has_alpha- aBOOLEAN. Wire it into any node that takes a boolean (WBLESSSwitch, or a logic node from other packs).
Installing it
ImageHasAlpha ships inside the ComfyUI-WBLESS grab-bag, so you install the whole pack:
cd ComfyUI/custom_nodes
git clone https://github.com/LaoMaoBoss/ComfyUI-WBLESS.git
then restart ComfyUI (or use ComfyUI Manager and search "ComfyUI-WBLESS"). No Python dependencies to install - the pack vendors everything in its lib/ folder - and no model downloads. The node shows up under the 🌈WBLESS category. Once it's in, it's a two-second node; the only real troubleshooting is the RGB-vs-RGBA confusion above. If you're feeding it something you believe has alpha and it says no, check what's upstream of it, not the node.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | 要检测透明通道的输入图像 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| has_alpha | BOOLEAN | — |