Nodes/ComfyUI-EditUtils/EditUtils: EditTextEncode lrzjason
ComfyUI Node

EditUtils: EditTextEncode lrzjason

The One Encode Node to Rule All the Edit Models in This Pack

By lrzjason·Created 7 months ago·Updated 16 days ago· 207
EditUtils: EditTextEncode lrzjason
  • clip
  • vae
  • model_config
  • configs
  • conditioning
  • latent
  • custom_output
  • main_image
  • mask
  • pad_info
prompt

EditTextEncode_EditUtils is the heart of this pack. It's the single encode node that Qwen-Image-Edit, Flux 2 Klein, Boogu, and Krea 2 workflows all route through - you tell it which model you're running via a model_config dictionary from one of the Model Config nodes, feed it your prompt and a chain of image configs, and it produces the conditioning, the starting latent, and a bag of intermediates. Understand this node and the entire pack reads the same.

Inputs: clip, vae, prompt, and model_config (a DICT - required) plus the optional configs list. Outputs: conditioning, latent, custom_output (the ANY bag), main_image, mask, and pad_info. Leave configs unconnected and the node does a plain text-only encode with a friendly console note - that's not a bug, it's the fallback for "I just want the text."

The routing is the design. model_config carries model_name and vae_unit, and the node switches on them. Qwen and Flux 2 Klein share one code path; Boogu gets its own early-return path (it encodes the prompt and vision-tower images together, attaches refs to both positive and negative conditioning, and reads negative_prompt from the config - which is why the Boogu one-shot node hands you a negative and this general node doesn't). Krea 2 sneaks through the Qwen path because its text encoder is Qwen-based and its VAE is the Qwen-Image VAE, which is exactly why Krea2ModelConfig_EditUtils reports model_name: "qwen".

What happens per image is where the mechanism lives. Each config's image is resized so its longest edge hits ref_longest_edge, aligned to the model's vae_unit (8 for Qwen/Boogu/Krea2, 16 for Klein), cropped or padded (ref_crop: "pad" letterboxes, which is what produces pad_info), and VAE-encoded into a reference latent. Every reference latent is then attached to the conditioning object under the reference_latents key. That key is the whole trick of the pack: it's how references travel invisibly to the sampler, and it's what the EditApply nodes read via their extra_conds patch. No extra wires, no parallel image inputs to the sampler - the references live inside the conditioning.

Three outputs carry the weight. conditioning goes to your sampler, refs riding along. latent is the main image's reference latent (the ref_main_image config flag picks which one; if none is flagged, the first config wins, and if there are no images you get a 1×4×128×128 zero latent - the classic "why is my edit blank" gotcha). pad_info is the padding dict you feed CropWithPadInfo_EditUtils after decode to ship the original framing. The rest - main_image, mask, custom_output (which holds ref_latents, vae_images, full_prompt, no_refs_cond, and more, depending on model path) - is for when you want the internals as wires, which the Output Extractors are built to do.

Practical notes from the author's own source: a mask on the main image gets baked into the latent as a noise_mask and echoed out the mask port; and if a later config claims ref_main_image, the first main image wins - there's only ever one. Install: ComfyUI Manager (search "EditUtils") or git clone https://github.com/lrzjason/ComfyUI-EditUtils into custom_nodes, restart. No dependencies; you bring the model, CLIP, and VAE.

Categoryadvanced/conditioning

Inputs (5)

NameTypeDefaultDescription
clipCLIP
vaeVAE
promptSTRING
model_configDICT
configsoptLISTList of image configuration dictionaries. When not provided, performs text-only encoding.

Outputs (6)

NameTypeDescription
conditioningCONDITIONING
latentLATENT
custom_outputANY
main_imageIMAGE
maskMASK
pad_infoANY