Nodes/ComfyUI_KimNodes/🍒Distribute_Icons / 分发图标
ComfyUI Node

🍒Distribute_Icons / 分发图标

Distribute_Icons scatters your icons inside a mask, not over the whole canvas

By wjl0313·Created 2 years ago·Updated 12 months ago· 54
🍒Distribute_Icons / 分发图标
  • scene_image
  • mask_image
  • IMAGE
icon_folder./icons
icon_size50
min_distance0
min_scale0.5
rotation_angle90

Randomly scatter icons onto a scene and most naive approaches paint icons over the whole canvas, including across each other and out into space. Distribute_Icons is smarter than that: you give it a mask, and icons only land inside the white regions of that mask, fully contained, with a configurable minimum distance between them. Think stickers on a defined area, emblems on a map region, or decorative icons sprinkled over a product shot without ever touching the sky.

It's one of the pack's icon-processing tools, and it's the "random" cousin of the grid-based IconDistributeByGrid: where that node arranges methodically, this one jitters. Each run is different (there's no seed input), which makes it great for organic-looking results and a poor fit for reproducible layouts.

How it works

You feed scene_image, a mask_image (white = allowed area), and a folder of icons. The node loads every .png/.jpg/.jpeg from icon_folder (default ./icons, relative to your ComfyUI working directory), thresholds the mask to find its white region, and then runs a placement loop: pick a random spot, check the icon's alpha pixels all fall inside the white area, check it clears the min_distance from already-placed icons, and if both pass, paste it with its alpha channel. Each icon also gets randomly scaled between min_scale and a hidden max_scale of 1.0, and randomly rotated within ±rotation_angle degrees. If it can't find a valid spot in 500 tries, it gives up and moves on - so don't expect perfection when the mask area is tiny.

The inputs that matter

  • icon_folder - point this at a real folder. The default ./icons almost certainly doesn't exist on your machine.
  • icon_size - target size icons are scaled to before placement.
  • min_distance - how far apart icons must sit (0 lets them touch).
  • min_scale / rotation_angle - the variety dials.
  • mask_image - the placement boundary. White = allowed.

Output: a single IMAGE, the scene with icons pasted.

Installation

Standard KimNodes pack install (Manager → "ComfyUI_KimNodes", or clone into custom_nodes), then restart. Needs cv2 (OpenCV) for the mask contour work - not in the pack's requirements.txt - so if the whole pack fails to appear, pip install opencv-python (plus ultralytics for the YOLO nodes) and restart.

Common issues

  • No icons appear - the classic. icon_folder doesn't exist or is empty; the node doesn't create it or warn loudly. Create the folder and drop in icons, and make sure the path resolves from your ComfyUI working directory.
  • Icons land outside where you expected - mask_image is a MASK input; if you feed a colored image instead, the thresholding can treat dark pixels as allowed. Feed a clean white/black mask.
  • Density too high or low - min_distance is the spacing control; raise it to spread icons out.
  • Not reproducible - by design. If you need the same layout twice, use IconDistributeByGrid (which has a seed) instead.

This node is at its best when you're decorating a bounded region with a varied set of icons and don't care that each run is unique. When you need consistency, its grid sibling is the better pick.

Category🍒 Kim-Nodes/🧩Icon Processing | 图标处理

Inputs (7)

NameTypeDefaultDescription
scene_imageIMAGE
mask_imageMASK
icon_folderSTRING./icons
icon_sizeINT5010–512
min_distanceINT00–512
min_scaleFLOAT0.50.1–10
rotation_angleINT900–180

Outputs (1)

NameTypeDescription
IMAGEIMAGE