RectangleContour
Grid-fill any rectangle
- rectangle_image
- stickers
- main_sticker
- image
RectangleContour is the square-cornered member of the WPX sticker-arrangement family. Where AnimalContour traces an organic outline and CircleContour builds concentric rings, this one detects a rectangle in your input image and fills it with a tidy grid of stickers - nested rectangles inside rectangles, like a matryoshka sticker sheet. It's the node you reach for when you want order, not scatter: product sticker packs, card backgrounds, and anything where the composition should read as deliberate rows rather than random tiling. Same pack (ComfyUI WPX Nodes), same story: no model, no key, pure CPU.
How it works
The node binarizes your rectangle_image, finds the largest contour, and takes its bounding box as the rectangle. It then generates n_scales concentric rectangles that shrink toward the center, keeping themselves centered. Inside each rectangle it lays a regular grid - the grid cell size is sticker_size × cell_size_factor - and drops a sticker at every grid point with a small random offset and a slight rotation. The one genuinely clever bit: stickers sitting on the rectangle's edges are aligned flush to the boundary and un-rotated, so the outer border reads as a clean frame instead of a jagged mess. After the nested layers, the main_sticker is pasted dead-center, scaled by main_sticker_size.
The inputs that matter
- rectangle_image - the shape that defines the box. Any rectangle-ish silhouette whose largest contour is the rectangle you mean.
- stickers - the fill pool. A batch of sticker images the node cycles through.
- main_sticker - the centerpiece.
- n_scales (4) - how many nested rectangle layers.
- sticker_size (280) and cell_size_factor (0.45) - sticker long side and how much of a grid cell a sticker fills. Factor too high and stickers overlap heavily; too low and the grid gets gappy.
- main_sticker_size (450) - centerpiece scale.
- crop_image (bool) + padding - trims transparent margins off sticker PNGs before arranging.
Output: a single image (RGBA), wire it to a preview or save node.
Installing
ComfyUI Manager → search "ComfyUI WPX Nodes" → install → restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/WangPengxing/ComfyUI_WPX_Node
# restart ComfyUI
No weights, no requirements file. The recurring pack gotcha: rtree and scipy are imported at startup, and if either is missing the entire WPX_Node menu disappears. pip install rtree scipy and restart.
Troubleshooting
- The grid isn't filling the whole rectangle.
cell_size_factoris low, so cells are smaller than the rectangle wants to be filled. Raise it toward 0.5–0.6. - Stickers spill past the edge. The outer layer aligns flush to the boundary, but a very wide sticker can still peek out. Shrink
sticker_sizerelative to your rectangle. [DEBUG]spam in the console - normal for this pack; the author left debug prints in every node.
Same caveats as the rest of the pack: 0.0.1, one early-2025 update, zero community footprint. It's a niche utility with a narrow job, but for "fill this box with a neat grid of stickers" there's nothing in the mainstream ecosystem that does it more directly.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| rectangle_image | IMAGE | — | |
| stickers | IMAGE | — | |
| main_sticker | IMAGE | — | |
| n_scales | INT | 41–10 | — |
| sticker_size | INT | 2801–1000 | — |
| main_sticker_size | INT | 4501–1000 | — |
| cell_size_factor | FLOAT | 0.450–1 | — |
| crop_image | BOOLEAN | false | — |
| padding | INT | 00–1000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |