Nodes/ComfyUI-Magic-Assistant/🧩 裁切缩回并合并 Magic Resize & Merge
ComfyUI Node

🧩 裁切缩回并合并 Magic Resize & Merge

The half of crop-and-stitch that keeps your other pixels intact

By shigjfg·Created 9 months ago·Updated 5 days ago· 45
🧩 裁切缩回并合并 Magic Resize & Merge
  • original_image
  • processed_image
  • crop_info
  • cropped_mask
  • image
◄upscale_methodlanczos►

What it is

Magic Resize & Merge is the second half of a two-node pair. MagicMaskCropResize cuts a padded square around your mask and hands you a CROP_INFO object describing exactly where that square came from; this node takes your edited crop plus that CROP_INFO, shrinks the crop back to the original crop size, and composites it into place. One output, image.

Boring on paper, but the reason the pair is worth installing is what this node refuses to do: it clones the original image and overwrites only the crop region, so every pixel outside your square comes back byte-identical. That's the whole point of the crop-edit-stitch pattern in 2026 - edit models like Qwen-Image-Edit and Flux 2 Klein regenerate the entire frame and drift everything slightly when they do, and the fix people converged on is to keep a mask and never let the untouched area through a VAE cycle. ComfyUI's old rule was "composite after inpainting"; this pair makes it a property of the graph instead of a habit.

How the merge works

It resizes processed_image to the target_size recorded in CROP_INFO (so a model that returned an odd size still lines up), matches the batch to original_image, then resizes again down to the crop's actual crop_box dimensions - rarely the same as your target, because the square got clipped at the frame edge.

Then it clips crop_box to the image bounds, grabs the matching slice of the resized crop, and writes it in. Wire cropped_mask and that's your alpha: out = crop * alpha + original * (1 - alpha), mask upscaled bilinearly and clamped. Don't wire it and alpha is 1.0 everywhere, which is a hard rectangular paste of the entire square - you just replaced everything inside it, painted region or not. Fine if you deliberately regenerated the whole crop, surprising if you expected the mask to count. Wire cropped_mask unless you have a reason not to.

One fallback: if the crop node reported mask_empty, this node skips compositing and returns the resized processed_image as-is - a whole-image resize at your target dimensions, not your original size. Don't be startled when an unmasked run comes back at a different resolution than it went in.

The inputs that matter

  • original_image - the untouched frame. If you didn't keep a separate wire from the original image when you cropped, go back and add one; feeding it the cropped image is a quiet way to get nonsense.
  • processed_image - whatever came out of your sampler or edit model. Doesn't have to be square or the same size as anything.
  • crop_info - from MagicMaskCropResize, and from nothing else. It's a custom type; if you pass something else the node raises crop_info must be the output of MagicMaskCropResize rather than quietly doing the wrong thing.
  • upscale_method - lanczos, again the right default. It's used twice, in both directions, so it's worth not setting to nearest-exact unless you enjoy stair-stepping.
  • cropped_mask - optional, and the softness dial. There is no blur or feather parameter on this node: the blend is exactly as soft as the mask you hand it. If you're seeing a visible square edge, that's either a missing mask or a hard-edged one.

Install

Same pack, same one clone. ComfyUI Manager → search ComfyUI-Magic-Assistant, or:

cd ComfyUI/custom_nodes
git clone https://github.com/shigjfg/ComfyUI-Magic-Assistant.git
cd ComfyUI-Magic-Assistant
pip install -r requirements.txt

Restart ComfyUI. The only two dependencies are openai and aiohttp, and this node needs neither of them at runtime - you're installing a 12-node pack to get a paste-back utility. That's the honest cost of the pair, and there's nothing to download or configure. The console prints a 🔮 [Magic Assistant] 已加载 (V1.4.3) banner on load; these nodes shipped in v1.4.3 on 2026-09-29, so you're early enough that the pack's own README section is the entire documentation.

Troubleshooting

A visible rectangle, or "why did my background shift". Almost always the un-wired cropped_mask. With it connected, only the mask's active area moves.

A visible seam even with the mask. Two causes. Hard-edged masks - paint with a few pixels of blur, or run the mask through a blur node before the crop. Or a crop so tight the model had no surrounding pixels to match local colour against; raise padding on MagicMaskCropResize to 96–128 and re-run.

Everything pasted back is squashed. Your edit model returned a different aspect ratio and the node is stretching it into the crop box. It resizes to the record, it doesn't letterbox. Set the model's output to match target_width/target_height, or change those on the crop node.

The whole pack vanished after you updated one file. The pack's __init__.py imports every module at startup, so one bad sibling takes all of them with it - including this one. Update every file, not just the one you wanted, and check for the console banner before debugging.

Category✨ Magic Assistant/Mask Edit

Inputs (5)

NameTypeDefaultDescription
original_imageIMAGE—
processed_imageIMAGE—
crop_infoCROP_INFO—
upscale_methodCOMBOlanczos6 options: nearest-exact, bilinear, area, bicubic, lanczos, bislerp
cropped_maskoptMASK—

Outputs (1)

NameTypeDescription
imageIMAGE—