create_Mask_match_shape
Deprecated — compositing a masked foreground onto a background
- bimg
- bmask
- fimg
- fmask
- composed_image
- new_background
- foreground_layer
- foreground_mask
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, defaultauto-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, defaultPreview) - 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.
Inputs (18)
| Name | Type | Default | Description |
|---|---|---|---|
| bimg | IMAGE | — | |
| bmask | MASK | — | |
| b_color | COMBO | blue | 5 options: black, white, red, green, blue |
| b_extrant_to_block | BOOLEAN | true | — |
| f_extrant_to_block | BOOLEAN | true | — |
| edge_detection | BOOLEAN | false | — |
| edge_thickness | INT | 11–100 | — |
| edge_color | COMBO | white | 5 options: black, white, red, green, blue |
| f_smoothness | INT | 10–150 | — |
| f_opacity | FLOAT | 1.000–1 | — |
| fimgopt | IMAGE | — | |
| fmaskopt | MASK | — | |
| f_x_offsetopt | INT | 0-500–500 | — |
| f_y_offsetopt | INT | 0-500–500 | — |
| scale_modeopt | COMBO | auto-in | 5 options: custom, width_align, height_align, auto-in, auto-out |
| f_scaleopt | FLOAT | 1.000.01–5 | — |
| f_rotopt | INT | 0-180–180 | — |
| image_outputopt | COMBO | Preview | 4 options: Hide, Preview, Save, Hide/Save |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| composed_image | IMAGE | — |
| new_background | IMAGE | — |
| foreground_layer | IMAGE | — |
| foreground_mask | MASK | — |