Nodes/ComfyUI WPX Nodes/AnimalContour
ComfyUI Node

AnimalContour

Fill an animal's outline with stickers in one pass

By WangPengxing·Created 2 years ago·Updated 2 years ago· 0
AnimalContour
  • animal_image
  • stickers
  • main_sticker
  • image
max_sticker_count130
spacing10
overlap_threshold_contour0.60
bg_sticker_size220
main_sticker_size380

AnimalContour is the flagship node of the ComfyUI WPX Nodes pack - the one that makes the "sticker collage in the shape of an animal" images the author's other nodes orbit around. You give it a bunny, a pile of baby-bear stickers, and one hero sticker, and it decorates the bunny's outline with stickers and fills the inside with more stickers. It's pure CPU image composition: no model, no API key, no weights to download. If you make sticker sheets or mascot collages for a living (this genre is huge in the WeChat-sticker world), this is the node you'll actually use. If you were hoping for a diffusion trick, it isn't - it's deterministic arrangement, and it's honest about that.

How it works

The mechanism is worth understanding because it explains every input. The animal_image is converted to grayscale and binarized, and OpenCV pulls out the largest contour. The node then does two passes:

  1. Along the contour. It samples evenly spaced points around the edge (that's spacing, in pixels), rotates each sticker to follow the tangent of the line so they hug the outline like a border, and checks each candidate against already-placed stickers for overlap.
  2. Inside the shape. It randomly drops stickers into the silhouette's interior, again gated by the overlap check, until it hits max_sticker_count or runs out of tries.

Finally it pastes your main_sticker dead-center in the animal's bounding box. The overlap check is a real IoU test against placed stickers, backed by an rtree spatial index so it doesn't crawl at hundreds of stickers.

The inputs that matter

  • animal_image - a white silhouette on black. This is the big gotcha: the binarization treats only pure white (255) as the shape. A soft, anti-aliased, grayscale silhouette will partially vanish. Give it a hard white-on-black mask.
  • stickers - a batch of background stickers. Pass several; the node cycles through them. Wire a single image and you get a one-sticker army.
  • main_sticker - the hero piece for the center.
  • max_sticker_count (default 130), spacing (10), overlap_threshold_contour (0.6) - the max IoU a new sticker may have against ones already placed. Lower it and stickers spread apart.
  • bg_sticker_size (220) / main_sticker_size (380) - the long side in pixels each sticker is scaled to.

Output is a single image (RGBA). Wire it to a preview or save node.

Installing

ComfyUI Manager → search "ComfyUI WPX Nodes", install, restart. Or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/WangPengxing/ComfyUI_WPX_Node
# restart ComfyUI

No models, no requirements file. The code does import rtree and scipy, which don't ship with every ComfyUI install - if all eight nodes in the pack show up as missing, that's usually why (see below).

Troubleshooting

  • Every node in the pack is missing after install. The pack imports rtree and scipy at startup; if either isn't installed, the whole WPX_Node menu disappears, not just this node. pip install rtree scipy and restart.
  • The shape comes out wrong or empty. Your silhouette has grayscale edges. Binarize it properly - white fill on pure black - before wiring it in.
  • Console is full of [DEBUG] shape spam. Normal; the author left debug prints in every node. Annoying, harmless.
  • Stickers look off-center or clipped. The animal_image's bounding box defines the main sticker's center. If your source image has dead space around the animal, crop it first.

One honest caveat: this is a 0.0.1 pack, updated in early 2025, with essentially no community footprint. It works as documented, but treat it as a tool for batch-compositing sticker art - not something with a long track record of edge-case fixes.

CategoryWPX_Node/main_image

Inputs (8)

NameTypeDefaultDescription
animal_imageIMAGE
stickersIMAGE
main_stickerIMAGE
max_sticker_countINT1301–1000
spacingINT101–100
overlap_threshold_contourFLOAT0.600–1
bg_sticker_sizeINT2201–1000
main_sticker_sizeINT3801–1000

Outputs (1)

NameTypeDescription
imageIMAGE