Nodes/painting-by-colors-generator/Paint by Numbers: overlay Numbers
ComfyUI Node

Paint by Numbers: overlay Numbers

Stamping the numbers onto your final sheet

By Chrisvenator·Created about a year ago·Updated about a year ago· 3
Paint by Numbers: overlay Numbers
  • input_image
  • numbers_image
  • overlaid_image
transparency1.00
white_threshold240
blend_modereplace
auto_scaletrue
scaling_methodlanczos

Paint by Numbers: overlay Numbers is the last mile of this pack - the node that actually writes the numbers onto your sheet. By this point you've flattened your image into color regions, run it through a lineart converter for the outlines, and asked Calculate numbers for a black-and-white sheet of digits. This node takes those digits and stamps them onto your lineart so you get the finished, printable coloring page.

The README describes it bluntly: it "writes all black pixels from numbers_image onto input_image." It's a compositing step, nothing more - and it's refreshingly simple to use.

How it works

It overlays one image onto another:

  1. Auto-scale the numbers image to match the input image's size, using scaling_method (lanczos by default - the right call for crisp digits, nearest is there if you're in a hurry and hate anti-aliasing).
  2. Build a mask from the numbers image: any pixel where any channel falls below white_threshold (default 240) counts as "number pixel." Since the calculator draws black numbers on white, this separates digits from background.
  3. Composite: where the mask is true, replace or blend the input pixels with the numbers pixels.

At transparency = 1.0 and blend_mode = "replace", it's a straight pixel swap - fastest path. Drop transparency or pick a blend mode and it starts mixing. The four blend modes are replace, multiply, overlay, and soft_light. For this use case, replace is almost always what you want; the others are there if you're overlaying onto a colored base and want the digits to sit in the image instead of on top of it.

The inputs that matter

Everything here is required in the node, and most of it you can leave alone:

  • input_image - the base you're stamping onto. Typically your inverted lineart, or the flat color image if you want the full colored-and-numbered version.
  • numbers_image - the output of Calculate numbers.
  • transparency (default 1.0) - 1.0 is fully opaque numbers. Drop it and digits go ghostly.
  • white_threshold (default 240, range 200–255) - what counts as "background." If your numbers image isn't pure white behind the digits, nudge this down.
  • auto_scale and scaling_method - whether to resize the numbers sheet to match your base. Leave auto_scale on; a size mismatch is the most common way this node silently does nothing useful.
  • blend_mode - see above; replace for a normal paint kit.

The output

One output: overlaid_image. Save it, print it, or feed it onward. That's the whole kit, done.

Installing and troubleshooting

Same pack, same install. ComfyUI Manager search "Painting-by-colors-generator", or:

cd ComfyUI/custom_nodes
git clone https://github.com/Chrisvenator/ComfyUI-Painting-by-colors-generator

then restart ComfyUI. No model files involved.

Two things bite people here. First, size mismatch with auto_scale off: if the numbers sheet and the base have different dimensions and you've disabled auto-scaling, the node crops or pads with white, which can eat your numbers. Keep auto_scale on unless you know the dimensions match. Second, "where did my numbers go": the mask logic treats anything below white_threshold as ink. If your numbers image has a gray or tinted background (say, from a color-managed lineart chain), pixels can read as "ink" everywhere - the overlay looks like a smudge. If it looks wrong, check the numbers sheet in isolation first; the fix is usually just re-running the calculator to get a clean white background.

Categoryimage/postprocessing

Inputs (7)

NameTypeDefaultDescription
input_imageIMAGE
numbers_imageIMAGE
transparencyFLOAT1.000–1
white_thresholdINT240200–255
blend_modeCOMBOreplace4 options: replace, multiply, overlay, soft_light
auto_scaleBOOLEANtrue
scaling_methodCOMBOlanczos4 options: lanczos, bicubic, bilinear, nearest

Outputs (1)

NameTypeDescription
overlaid_imageIMAGE