VAEEncodeBatch
One latent batch from many images (no wiring gymnastics)
- vae
- LATENT
ComfyUI's built-in VAEEncode takes one image and hands you one latent. That's fine until you want to img2img a whole folder of references at once, and suddenly you're chaining ImageBatch into VAEEncode or hunting for some latent-joiner that half the internet says is broken. VAEEncodeBatch is the pack's answer: feed it N images, get back a single LATENT whose batch dimension is N. No extra nodes, no copy-pasted wiring.
It's a simple utility node, and it says so. It's part of Bmad's simple_utilities.py, which loads unconditionally - no openCV, no scikit-image, nothing. Just your VAE and torch.
How it works
The node is almost embarrassingly thin under the hood, and that's a compliment. Internally it instantiates ComfyUI's own VAEEncode, runs each incoming image through the standard vae_encode_crop_pixels() (the same multiple-of-8 crop the built-in node does), drops the alpha channel, encodes each one, then torch.cats the latents along the batch axis. One encode, one list, one batch.
The part that trips everyone up is that the image inputs don't exist yet when you drop the node. The declared schema is just two things:
inputs_len(INT, default 3, min 2, max 32) - how many image slots you wantvae(VAE) - a loaded VAE, from a VAELoader or a checkpoint's baked-in one
The image_1 … image_N slots are generated on demand. Change inputs_len, then right-click the node and hit "update Inputs". That's the pack's ❔ convention in the README - the little "additional options when right-clicking" icon. Forgetting this is the single most common way to think the node is broken; it isn't, it's just bashful.
The output is one LATENT, wired straight into a KSampler's latent_image (or any sampler that takes a latent). Run it at low denoise and you've got batch img2img in one pass; combine it with the pack's Conditioning Grid nodes if you want different prompts per image instead of one shared prompt for the whole batch.
Gotchas worth knowing
- Same resolution in, or nothing out. Because the latents get
cat'd along the batch axis, every image must encode to the same height and width. The node crops to multiples of 8, but it won't resize. Feed it a 1024×1024 and a 512×512 and you'll get a shape-mismatch error from the concat, not a helpful message. - Minimum of 2.
inputs_lenbottoms out at 2, because for one image you should just use the stockVAEEncode. This node exists to save you a step, not to reinvent it. - Alpha is ignored. RGBA images get their fourth channel sliced off (
pixels[:, :, :, :3]). That's standard - the VAE only consumes RGB anyway - but don't expect transparency to survive. - It's lossy, like any encode. VAE encode/decode is not lossless, and that loss compounds if you chain passes. For pure batching this is exactly what you want; just don't build a round-trip on top of it.
Install
ComfyUI Manager is the easy route: search comfyui_bmad_nodes and hit install, then restart ComfyUI. Or do it by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_bmad_nodes
then restart. This particular node needs nothing extra, but the pack's requirements.txt (opencv-python, scikit-image, gray2color, simpleeval) is required for the CV and Color Clip nodes - let Manager install those or run pip install -r requirements.txt yourself.
Bottom line
If you've ever squinted at a latent-joining problem and wished it were just an input count, this is your node. It's not flashy, it doesn't have opinions, and it won't fix your workflow - it just quietly does the one repetitive thing you were about to do by hand, for up to 32 images at a time. Some days that's exactly the kind of node you need.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| inputs_len | INT | 32–32 | — |
| vae | VAE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |