BK Gradient Image
Gradient backgrounds and fades without ever leaving ComfyUI
- IMAGE
You need a smooth fade to composite behind text, blend two images together, or use as a mask ramp - and you don't want to alt-tab to a design tool to make one. BK Gradient Image generates a gradient image at whatever size you ask, directly in the graph.
It's part of the ComfyUI_BaiKong_Node pack, the no-models, CPU-only designer toolkit for color and layout. There are zero model downloads and zero GPU calls here - this node is pure numpy and PIL math, which means it runs instantly and is safe to throw into any workflow as a background generator.
How it works - read this before you use it
The key detail is that this is not a two-color gradient. You give it one hex color, and it builds an RGBA image where the RGB channels stay constant and the alpha ramps from transparent to opaque between start_position and end_position. The area before the start stays fully transparent; the area after the end is fully opaque.
That's exactly the shape you want for compositing: it's a fade-in of a solid color, which you can paste onto a canvas, composite behind a subject, or feed through as a feathered mask. If you were expecting a blue-to-red sweep, this isn't it - there's no second color input, so "gradient" here means "fade," not "blend between two colors."
direction picks horizontal or vertical for the ramp, and reverse flips which side is opaque. start_position/end_position are 0–1 fractions along the axis - so start=0, end=0.5 fades in across the left half and then holds solid, and start=0.4, end=0.6 gives you a tight fade band in the middle.
Inputs and outputs
- hex_color - the solid color to fade in (default
#FFFFFF). - width / height - output size in pixels (defaults 512×512; a value of 0 is clamped up to 1).
- start_position / end_position - where the fade begins and ends, 0 to 1.
- direction -
horizontalorvertical. - reverse - flip the opacity ramp.
Output is a single IMAGE (RGBA), ready to wire into a composite node, an image-merge, or a mask input.
Install
Shared with the whole pack:
cd ComfyUI/custom_nodes
git clone https://github.com/JayLyu/ComfyUI_BaiKong_Node
cd ComfyUI_BaiKong_Node
pip install -r requirements.txt
Restart ComfyUI, or search "ComfyUI_BaiKong_Node" in ComfyUI Manager. The dependencies (scikit-learn, scipy, opencv-python, scikit-image, matplotlib) are shared and CPU-only.
Gotchas
Bad hex falls back to white with a warning - it won't crash. The subtle one is that this node's gradient is built through alpha, so if you feed the output into something that flattens to RGB before compositing (or a node that ignores the alpha channel), you'll get a solid block of your color instead of a fade. Keep the RGBA intact until the composite step and you're fine. Also note the ramp is linear - if you want eased fades, you'll be doing the easing somewhere downstream.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| hex_color | STRING | #FFFFFF | — |
| width | INT | 512 | — |
| height | INT | 512 | — |
| start_position | FLOAT | 0.000–1 | — |
| end_position | FLOAT | 1.000–1 | — |
| direction | COMBO | horizontal | 2 options: horizontal, vertical |
| reverse | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |