Nodes/ComfyUI-Apt_Preset/Image_CnMapMix
ComfyUI Node

Image_CnMapMix

A Photoshop-style layer blender for building composite control maps

By cardenluo·Created 2 years ago·Updated 18 days ago· 309
Image_CnMapMix
  • image1
  • image2
  • mask2
  • IMAGE
bg_colorimage
blur_10
blur_20
diff_sensitivity0.00
diff_blur0
blend_mode
blend_factor0.50
contrast1.0
brightness0.00
mask2_smoothness0
invert_maskfalse
image1_min_black0.00
image1_max_white1.00
image2_min_black0.00
image2_max_white1.00

ControlNet conditions generation on a spatial map - edges, depth, pose. Sometimes one map isn't enough: you want the edges from one preprocessor pass and the depth structure from another, or you need a mask built from exactly where two conditioning images disagree. Image_CnMapMix is a general two-layer blender built with that job in mind - the "CnMap" in the name is short for "control(net) map" - though there's nothing stopping you using it as a plain layer-blend tool for any two images, ControlNet or not.

How it works

image1 and image2 (both optional - you can drive the node off just one plus bg_color if you want) each get an independent levels pass first: image1_min_black/image1_max_white and their image2_* equivalents remap each layer's black and white points before anything else happens, the same idea as Levels in Photoshop. blur_1/blur_2 soften each source. Then they're combined through one of ten blend_mode options - normal, multiply, screen, overlay, soft_light, difference, add, subtract, lighten, darken - at a blend_factor (opacity, 0–1), with a final contrast/brightness grade applied to the result.

There's also a built-in diff generator: diff_sensitivity and diff_blur build an automatic mask from wherever image1 and image2 disagree - handy for spotting exactly where two conditioning maps diverge without painting anything by hand. An optional mask2, plus mask2_smoothness and invert_mask, give you manual control over the blend region instead. bg_color (image/white/black/gray) is the fallback backdrop when there's nothing behind the blend.

The inputs and outputs that matter

  • blend_mode, blend_factor - the actual combination math and its strength.
  • image1, image2 (both optional) - your two layers.
  • diff_sensitivity/diff_blur vs mask2/mask2_smoothness - two different ways to control where the blend applies: automatic (from the images' own difference) or manual (a mask you supply).
  • image1_min_black/image1_max_white/image2_min_black/image2_max_white - per-layer levels, applied before blending.
  • Output: IMAGE - the blended result.

How to install it

Via ComfyUI Manager: search ComfyUI-Apt_Preset, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git

Windows: install.bat. Linux/Mac: pip install -r ComfyUI-Apt_Preset/requirements.txt in your venv. Restart ComfyUI. Nothing to download for this node - pure image math - though the pack's dependency list is heavier than that alone would suggest, since Apt_Preset (~300 GitHub stars, MIT, actively updated) bundles GGUF loading, audio and video tooling alongside its image nodes in one install.

Common issues & troubleshooting

Result looks like image1 untouched. blend_mode has no listed default in the schema, so don't assume it's on "normal" - check what it's actually set to. Also check blend_factor isn't sitting near 0, which would make any blend mode look like a no-op.

Two maps that don't line up. If image1 and image2 come from different preprocessor passes at different resolutions (a canny map here, a depth map there), this node doesn't handle the mismatch for you - line them up first with Image_CnMap_Resize before feeding them in.

Diff mask coming out empty or solid. diff_sensitivity has a narrow range (−0.2 to 0.2) - small moves matter a lot more than they look like they should. Nudge it in tiny steps rather than large jumps if the automatic diff mask isn't picking up the difference you expect.

CategoryApt_Preset/image/ImgLayer

Inputs (18)

NameTypeDefaultDescription
bg_colorCOMBOimage4 options: image, white, black, gray
blur_1INT00–1000
blur_2INT00–1000
diff_sensitivityFLOAT0.00-0.2–0.2
diff_blurINT00–1000
blend_modeCOMBO10 options: normal, multiply, screen, overlay, soft_light, difference, +4
blend_factorFLOAT0.500–1
contrastFLOAT1.00–3
brightnessFLOAT0.00-1–1
mask2_smoothnessINT00–500
invert_maskBOOLEANfalse
image1_min_blackFLOAT0.000–1
image1_max_whiteFLOAT1.000–1
image2_min_blackFLOAT0.000–1
image2_max_whiteFLOAT1.000–1
image1optIMAGE
image2optIMAGE
mask2optMASK

Outputs (1)

NameTypeDescription
IMAGEIMAGE