π Bitmap Expand Canvas
Pad a bitmap with breathing room before ControlNet sees it
- BITMAP
- BITMAP
A shape that runs edge-to-edge on your canvas is a shape the model has to deal with. Bitmap Expand Canvas lets you add a border around a bitmap - black or white, in whatever thickness you want - so your guide sits inside the frame instead of hugging it. It sounds like busywork. Then you try conditioning with a star that touches all four edges and the model starts inventing stuff in the corners.
In Dream Painter terms this is the "give it room" node. You generate geometry, you realize the composition needs margin, and instead of regenerating shapes at a smaller scale you just pad the bitmap. Combined with Shape Center & Fit upstream (which normalizes shapes into the 0β1 box) you get a clean recipe: fit the shape, render it, then decide how much empty canvas surrounds it.
How it works
Straightforward and fully deterministic. The node builds a new bitmap of width + 2Γborder by height + 2Γborder, fills it with your chosen color (black or white), then pastes the original bitmap into the middle - so the border is added symmetrically on all four sides. A border_pixels of 0 is a no-op that returns the input unchanged, and the output stays a one-bit bitmap like everything else in this pack.
One detail that matters: the fill color is the background, and it's black by default in the sense that black is the first choice in the enum. If your shapes are drawn white-on-black (the pack's default), add a black border and your outline just floats in more black. If you add a white border instead, you get a frame that reads as "shape, then empty white region" - pick based on what your downstream ControlNet preprocessor expects.
Inputs and outputs
- BITMAP - the bitmap to pad.
- color -
blackorwhite, the border fill. - border_pixels - border thickness in pixels (default 16, min 0).
Output:
- BITMAP - the padded bitmap.
Installing
From the Dream Painter pack (comfyui-dream-painter, alt-key-project). ComfyUI Manager β Install Custom Nodes β search Dream Painter β install β restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/alt-key-project/comfyui-dream-painter
cd comfyui-dream-painter
pip install -r requirements.txt
No models or downloads - the whole pack is PIL math.
Common issues
Watch out for the crop/pad trap: Bitmap Crop Center can cut a bitmap down, and Bitmap Expand Canvas grows it back, but they don't remember each other. Padded borders are just pixels; if you then crop again, the center shifts. If your guide looks off-center relative to the composition, that's the workflow to re-check. Also, if you're feeding the result straight to a ControlNet that expects a fixed canvas (say 512Γ512), pad to the exact target - Expand Canvas won't resize anything, it only adds a border.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| BITMAP | BITMAP | β | |
| color | COMBO | 2 options: black, white | |
| border_pixels | INT | 16 | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BITMAP | BITMAP | β |