Nodes/ComfyUI-Apt_Preset/pre_mul_ref_latent
ComfyUI Node

pre_mul_ref_latent

Feed up to four reference images into your conditioning

By cardenluo·Created 2 years ago·Updated 18 days ago· 309
pre_mul_ref_latent
  • context
  • ref_latent_img1
  • ref_latent_img2
  • ref_latent_img3
  • ref_latent_img4
  • context
  • positive

This node exists because editing and multi-image-composition models - Qwen-Image-Edit, Flux Kontext, and their relatives - take reference images best when they're fed as reference latents, not just stitched into the prompt. Handing the model a reference latent lets it blend the new content with the surrounding context rather than treating the reference as a disconnected instruction, which is exactly the trick the wider community reaches for when getting a modern edit model to respect an existing image: convert your reference to a latent and feed it in as conditioning alongside the text. pre_mul_ref_latent wraps that pattern for up to four reference images at once, which matters because current edit models (2509-era Qwen-Image-Edit onward) are built to take multiple inputs for composition - person plus product, person plus scene, and so on.

How it works

You wire up to four images into ref_latent_img1 through ref_latent_img4. The node encodes each into a latent and folds them into the positive conditioning it emits, alongside the context bundle it received (passed straight through). Nothing here decides how the model should use each reference - that's still the job of your text prompt and whatever conditioning node feeds into this one upstream. This node's whole job is getting the reference images into the conditioning stream in the shape the model expects, without you hand-building the encode-and-concatenate plumbing yourself.

The inputs and outputs that matter

  • context (required) - the run-context bundle carrying model/clip/vae, threaded through from an upstream loader node in this pack.
  • ref_latent_img1ref_latent_img4 (all optional, IMAGE) - your reference images. Use as many or as few as the composition needs; a single-subject edit might only need one, a person-plus-product-plus-background shot could use all four.
  • Outputs: context passthrough and positive (CONDITIONING) - wire positive into your sampler alongside whatever negative conditioning you're using elsewhere.

There's no strength or weight control per reference image here - if you need to bias one reference over another, that has to happen upstream (crop it tighter, or route it through a different conditioning path) rather than in this node.

How to install it

Search ComfyUI-Apt_Preset in ComfyUI Manager and install, or clone it manually:

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

install.bat handles dependencies on Windows; on Linux or Mac open it to see the actual pip installs and run those, or let ComfyUI Manager resolve missing packages the first time you load a workflow using this pack. No model weights ship with this node - it works with whatever model your context is already carrying.

Common issues & troubleshooting

References blend into mush instead of composing cleanly. This is a known limitation of reference-latent conditioning on current edit models, not something specific to this node: unedited or reference-driven regions come back close to the input but not identical, and the effect compounds the more references you stack. If you need pixel-exact fidelity on one of the references (a logo, a face), don't lean on this node alone - inpaint that region back in afterward with a masked crop-and-stitch pass.

One reference image dominates and the others barely show up. With no per-image weighting, this node treats all connected references roughly equally at the encoding stage; if one reference is visually much busier or higher-contrast than the others, it can end up carrying more weight in practice. Try cropping busy references tighter to the subject you actually want represented.

Only using one or two references and unsure if that's fine. It is - all four inputs are optional, and the node works the same whether you wire one or all four.

CategoryApt_Preset/chx_tool/conditioning

Inputs (5)

NameTypeDefaultDescription
contextRUN_CONTEXT
ref_latent_img1optIMAGE
ref_latent_img2optIMAGE
ref_latent_img3optIMAGE
ref_latent_img4optIMAGE

Outputs (2)

NameTypeDescription
contextRUN_CONTEXT
positiveCONDITIONING