Light-Tool: Add solid color background V2
Same solid backdrop, but now with margins and auto-square
- image
- image
The V2 of Light-Tool: AddBackground is the same solid-color compositor as the original, but it adds the two things you'll actually want when you're not just slapping a cutout on white: configurable margins on each side, and an auto-square mode. If you're producing thumbnail sheets, square-profile product shots, or just leaving breathing room around a subject, this is the one to reach for.
How it works
The compositing math is identical to the original - foreground weighted by alpha over a solid color, so your semi-transparent edges blend cleanly instead of going hard and jaggy. The difference is the canvas. Before compositing, V2 grows the canvas by the four margins you specify and centers your image inside it.
The square toggle is the sleight of hand worth knowing about: when on, the node compares width and height and silently adds the difference to the top/bottom or left/right margins, so the output is a perfect square with your subject centered in it. You don't have to do the arithmetic yourself, which is the whole point of the node. Say your cutout is 1024×768 - flip square on and you get a 1024×1024 canvas with the subject centered, the extra space distributed evenly.
The inputs that matter
- image - the IMAGE tensor you're flattening.
- color_hex (default
#FFFFFF) and use_hex / R / G / B - same color machinery as V1.use_hexon means the#RRGGBBstring wins; off means the three 0–255 ints. - square - auto-expand to a square canvas. Off by default.
- left_margin, right_margin, top_margin, bottom_margin - extra padding in pixels on each edge, all defaulting to 0.
Output is one image tensor - fully opaque, ready for VAE encode, Save Image, or whatever's next.
When it beats the plain AddBackground
Honestly, if all you're doing is flattening a cutout onto a backdrop, V1 is simpler and you should use it. V2 earns its keep in two spots:
- Platform-ready output. Square Instagram posts, marketplace photos, or any slot with a strict aspect ratio - the
squaretoggle plus a margin or two gets you there in one node instead of three. - Workflows where canvas size is load-bearing. If your latent or VAE encode needs specific dimensions, having the margins be explicit inputs you can wire to an integer from another node is much nicer than hand-editing a pixel value inside a crop.
Gotchas
Same hex trap as V1 - with use_hex on, the string must be # plus exactly six hex digits or it throws a ValueError. And one thing the README doesn't shout about: V2 keeps the flattening behavior, so the output has no alpha. That's correct for compositing, but if you need the transparency preserved for a later step, this is the wrong node. Same install as the rest of the pack: ComfyUI Manager, search ComfyUI-Light-Tool, or clone and pip install -r requirements.txt from the custom_nodes directory, then restart.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| color_hex | STRING | #FFFFFF | — |
| use_hex | BOOLEAN | true | — |
| R | INT | 2550–255 | — |
| G | INT | 2550–255 | — |
| B | INT | 2550–255 | — |
| square | BOOLEAN | false | — |
| left_margin | INT | 0 | — |
| right_margin | INT | 0 | — |
| top_margin | INT | 0 | — |
| bottom_margin | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |