Nodes/XB_ToolBox/XB-BOX - 🖼️ FLUX多图编码
ComfyUI Node

XB-BOX - 🖼️ FLUX多图编码

Stuff up to nine reference images into a Flux conditioning, in one node

By wjluoxiao·Created 5 months ago·Updated 6 days ago· 302
XB-BOX - 🖼️ FLUX多图编码
  • positive
  • negative
  • vae
  • image1
  • 正面条件
  • 负面条件
longer_edge1024

Flux workflows have a standard trick for reference images: take the reference, VAE-encode it, and attach it to the conditioning as a reference_latents entry so the model treats it as guidance rather than just a prompt word. Do that with one image and it's three nodes. Do it with several - a character sheet, a style sample, a composition reference - and the wiring multiplies fast. XB_FluxMultiImageEncode bundles that whole chain into one node and lets you add reference images until your graph's ambition runs out (the ceiling is nine).

This is the node you reach for on any Flux task where "show, don't tell" is doing the heavy lifting: character consistency, style transfer from a sample, product shots keyed to a reference photo. It's the pack's answer to the manual ReferenceLatent dance, and it leans on the stock ComfyUI pieces under the hood.

How it works

Under the hood it's a tidy wrapper around ComfyUI's own machinery - ResizeImagesByLongerEdgeNode for the resize, VAEEncode for the latent, and the standard reference_latents conditioning append. The wrapper's value is the orchestration: every image gets resized to the same longer_edge (default 1024), encoded, and each latent is appended to both the positive and negative conditioning chains, so the reference set travels with the prompt.

The dynamic input trick does the heavy lifting: image1 is required, then connecting an image2 makes a slot appear, up to nine. No pre-declared nine-port blob cluttering the node when you only need two.

The inputs that matter

  • positive / negative - your existing text-encoded conditioning, usually from a CLIPTextEncode or DualCLIPLoader path. The reference latents get appended to both.
  • vae - the VAE used to encode the references. Same one you decode with, please.
  • image1 (+ image2 … image9) - the reference images. They don't need matching sizes; the node normalizes the longer edge.
  • longer_edge - 64–8192, default 1024. This is the resolution every reference gets resized to before encoding. Higher keeps detail, lower saves VRAM. For a character sheet, 1024–1536 is the sweet spot.

The outputs

Two conditioning wires: 正面条件 (positive) and 负面条件 (negative) - both CONDITIONING, both carrying your text plus the stacked reference latents. They feed your Flux sampler exactly where the original positive/negative would have gone.

Install and gotchas

Standard XB_ToolBox install: Manager → XB_ToolBox, or git clone into custom_nodes, restart. No extra models - it uses your existing VAE.

The gotchas are Flux-mechanics gotchas more than node gotchas. Adding references as reference_latents changes how the model weighs your prompt - the more images you stack, the more the generation anchors to them and the less the text matters, so don't be surprised when a five-image stack ignores your "no hands" prompt line. And every extra reference costs encode time plus VRAM during sampling; with all nine you're effectively conditioning on a small gallery. Keep the count where the task needs it, not at the ceiling, and remember the references influence both positive and negative - a confusing negative that's full of reference latents is doing something subtle to your generations.

CategoryXB_ToolBox/FLUX

Inputs (5)

NameTypeDefaultDescription
positiveCONDITIONING
negativeCONDITIONING
vaeVAE
image1IMAGE
longer_edgeINT102464–8192

Outputs (2)

NameTypeDescription
正面条件CONDITIONING
负面条件CONDITIONING