Nodes/ComfyUI-RefineNode/RefineNode Reference Image Process
ComfyUI Node

RefineNode Reference Image Process

Stop Qwen-Image-Edit from eating mismatched inputs

By 1Kynx·Created 4 months ago·Updated 26 days ago· 30
RefineNode Reference Image Process
  • image1
  • image2
  • image3
  • info
  • image1
  • image2
  • image3
  • info
fit_kontext_sizetrue
resize_methodlanczos
crop_modecrop

Feed a target image, a reference image, and a mask into Qwen-Image-Edit at three different resolutions and you get three problems: the model either errors, or - worse - quietly edits the wrong region because the mask and the image it's supposed to line up with are different sizes. RefineNode Reference Image Process exists to make that impossible. It resizes and aligns all three inputs onto exactly the same canvas, then remembers the transform so the result can be pasted back where it came from.

It's the alignment step in every workflow from ComfyUI-RefineNode, the pack the author built to automate the mask-prep / reference-align / paste-back slog around the RefineAnything LoRA. The node itself is model-agnostic - it just reshapes images. But the pack's example workflows use it with Qwen-Image-Edit 2511, and that's the pairing that makes sense.

How it works

You connect three slots: image1 (required, usually the target refinement image), image2 (optional, usually the reference image), and image3 (optional, usually the target mask or spatial_mask_image). The node picks a target size - Flux Kontext-style if fit_kontext_size is on (the default), or roughly 1024×1024 rounded to multiples of 8 if you turn it off - and resizes every connected image to it.

Two settings matter beyond that:

  • resize_method - one method for all images, lanczos by default. Leave it.
  • crop_mode - crop center-crops each image to the target aspect ratio (default), disable just squashes to size, fill preserves aspect ratio and pads with black. fill is the one to reach for when the crop would chop off part of a logo or product.

The info input is the interesting bit. When you feed it the REFINENODE_INFO from RefineNode Preprocess Mask, the node records its resize/crop/fill transform inside that info. Downstream, RefineNode Paste Back reads that record to put the generated result back at the exact right position on the original. Forget the info wire and you've got a refined patch with no home.

The three outputs

image1, image2, and image3 - the processed trio, exactly matching sizes. If you left image2 or image3 disconnected, you get a blank placeholder instead of an error, which is how the reference-free workflow gets away with only one image. The fourth output is the updated info, which you should pass straight to Paste Back.

One behavior worth knowing before it surprises you: when image1 comes from a multi-mask Preprocess Mask (a list of region crops), each list item is processed in sequence, and a single connected image2 is reused for all of them. One clean reference image, applied to every region job. That's exactly what you want for "fix all five bad spots on this one product" workflows.

Installing and running it

The pack installs the usual way - ComfyUI Manager, search "ComfyUI-RefineNode", or:

cd ComfyUI/custom_nodes
git clone https://github.com/1Kynx/ComfyUI-RefineNode.git

Restart ComfyUI. There's no requirements.txt; the nodes run on plain numpy/torch/PIL. The heavy part is the model stack: the included workflows load qwen_image_edit_2511_fp8mixed.safetensors, qwen_2.5_vl_7b_fp8_scaled.safetensors, and qwen_image_vae.safetensors, plus the RefineAnything LoRA from Hugging Face and a 4-step Lightning LoRA. This node doesn't need any of those by itself - they're only needed for the end-to-end workflow.

Gotchas

  • In the included workflows' Edit Model Reference Method node, avoid index_timestep_zero. The author and README both warn it produces a noticeable color shift; index and the other options hold up fine.
  • Keep info wired end-to-end. It's the only thing that lets Paste Back reverse the alignment this node did.
  • If results look cropped, you're on crop mode and the aspect ratio is fighting you - switch to fill.
CategoryRefineNode

Inputs (7)

NameTypeDefaultDescription
image1IMAGE
fit_kontext_sizeBOOLEANtrue
resize_methodCOMBOlanczos5 options: lanczos, area, bicubic, bilinear, nearest-exact
crop_modeCOMBOcrop3 options: crop, disable, fill
image2optIMAGE
image3optIMAGE
infooptREFINENODE_INFO

Outputs (4)

NameTypeDescription
image1IMAGE
image2IMAGE
image3IMAGE
infoREFINENODE_INFO