Nodes/ComfyUI-Apt_Preset/create_Mask_match_shape
ComfyUI Node

create_Mask_match_shape

Deprecated — compositing a masked foreground onto a background

By cardenluo·Created 2 years ago·Updated 17 days ago· 309
create_Mask_match_shape
  • bimg
  • bmask
  • fimg
  • fmask
  • composed_image
  • new_background
  • foreground_layer
  • foreground_mask
b_colorblue
b_extrant_to_blocktrue
f_extrant_to_blocktrue
edge_detectionfalse
edge_thickness1
edge_colorwhite
f_smoothness1
f_opacity1.00
f_x_offset0
f_y_offset0
scale_modeauto-in
f_scale1.00
f_rot0
image_outputPreview

Straight up front: this node's own category in the pack is literally named "🚫Deprecated" - that's not an inference, it's how the author filed it in the node menu. If you're starting a new workflow, use create_Mask_match_shape2 instead; it does the same job with cleaner semantics. This article exists because the node still ships, still works, and you'll still run into it in older shared workflows.

What it is and why it existed

create_Mask_match_shape composites a masked foreground image onto a masked background image, sizing and placing the foreground to match the background's mask shape - the "match shape" in the name. It's a full compositing tool: not just "paste image A onto image B," but paste it while automatically fitting it to a target region, with options for edge outlining and opacity control.

How it works

You give it a background (bimg + bmask) and, optionally, a foreground (fimg + fmask). b_color picks a fill color when the background needs one. b_extrant_to_block and f_extrant_to_block (both default true) read as "extract to bounding block" - cropping background and foreground down to their respective mask's bounding box before compositing, rather than working with the full uncropped canvas. scale_mode controls how the foreground is sized against the background region: custom for manual, width_align/height_align to match one dimension, or auto-in/auto-out (the default) to automatically fit the foreground inside or around the background's masked area. f_x_offset/f_y_offset, f_scale, and f_rot give you manual placement, scale, and rotation on top of whatever the scale mode already did. edge_detection (default false) optionally outlines the composited edge in edge_color at edge_thickness, for a cutout/sticker look. f_smoothness feathers the foreground mask's edge, and f_opacity controls blend strength.

Inputs and outputs that matter

  • bimg / bmask (required) - the background image and its mask.
  • fimg / fmask (optional) - the foreground image and its mask.
  • scale_mode (optional, default auto-in) - how the foreground gets fit to the background region.
  • f_opacity (0–1, default 1) - how strongly the foreground blends in.
  • image_output (optional, default Preview) - Hide/Preview/Save/Hide+Save, controlling what this node does with its result beyond just outputting it.

Outputs: composed_image (the final composite), new_background, foreground_layer, and foreground_mask - the composite plus its constituent pieces, useful if you need to inspect or re-use just the foreground layer downstream.

Installing it

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

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

Run install.bat on Windows for dependencies; on Linux/Mac install the requirements yourself. No model downloads needed - this is compositing math, not inference.

Common issues

The single most important thing to know about this node is the one at the top of this article: it's deprecated in the pack's own menu. If you're building anything new, go straight to create_Mask_match_shape2 - same job, an explicitly documented auto_in/auto_out behavior instead of guessing, and a proper 9-position alignment grid instead of manual offsets only.

If you're maintaining an existing workflow that already uses this node, it should keep functioning - deprecated in this pack's convention means "kept for compatibility," not "removed." As with the rest of ComfyUI-Apt_Preset: it's a large pack, and at least one user has reported an IMPORT FAILED error at ComfyUI startup after installing it. Check the console log if this node doesn't appear.

CategoryApt_Preset/🚫Deprecated/🚫

Inputs (18)

NameTypeDefaultDescription
bimgIMAGE
bmaskMASK
b_colorCOMBOblue5 options: black, white, red, green, blue
b_extrant_to_blockBOOLEANtrue
f_extrant_to_blockBOOLEANtrue
edge_detectionBOOLEANfalse
edge_thicknessINT11–100
edge_colorCOMBOwhite5 options: black, white, red, green, blue
f_smoothnessINT10–150
f_opacityFLOAT1.000–1
fimgoptIMAGE
fmaskoptMASK
f_x_offsetoptINT0-500–500
f_y_offsetoptINT0-500–500
scale_modeoptCOMBOauto-in5 options: custom, width_align, height_align, auto-in, auto-out
f_scaleoptFLOAT1.000.01–5
f_rotoptINT0-180–180
image_outputoptCOMBOPreview4 options: Hide, Preview, Save, Hide/Save

Outputs (4)

NameTypeDescription
composed_imageIMAGE
new_backgroundIMAGE
foreground_layerIMAGE
foreground_maskMASK