FD Vae Encode If Any
VAE-encode if you can — otherwise a blank latent, no drama
- pixels
- vae
- Latent
This is the cleverest node in the FD pack, and it solves a real workflow problem: branching a graph so it handles both text-to-image and image-to-image without erroring. Normally those are two different graph shapes - txt2img starts from an empty latent, img2img starts from a VAE-encoded image - and a node that needs one or the other just breaks the other branch. Feidorian_VaeEncodeIfAny (FD Vae Encode If Any) refuses to break. It encodes if you give it the pieces, and if you don't, it hands you a blank latent and moves on.
How it works. Both inputs - pixels (IMAGE) and vae (VAE) - are optional. The logic is short and honest:
- If either is missing, you get an empty latent: a 1×4×64×64 tensor of zeros, which decodes/encodes to a 512×512 canvas.
- If both are present, it crops the pixels to a multiple of 8 (centered crop, so off-by-a-few-pixel images don't crash the VAE), drops any alpha channel, and runs the VAE encode the same way ComfyUI's core VAEEncode does.
So one node, two behaviours, and whichever branch of your workflow is active just gets what it needs. That's the "If Any" in the name: encode if any VAE and pixels happen to be connected.
Why you'd reach for it. You're building a workflow with a switch somewhere - an A/B between a fresh generation and a passed-in image, say, or a batch pipeline that sometimes starts from a reference and sometimes doesn't. Wire the incoming image to pixels, your VAE to vae, and this node becomes a merge point that never throws. It's the glue that lets one graph serve both modes.
Inputs and output. pixels (optional IMAGE), vae (optional VAE), one output Latent (LATENT) that feeds straight into a KSampler's latent input. That's the whole surface.
The honest caveats. The fallback latent is hardcoded at 512×512. If your model's native resolution is 1024 (SDXL and friends), a fallback latent at 512 gives you a small, then-upscaled result - you'll want a size-adjusting node after it, or you'll wonder why the txt2img branch renders tiny. Second, this is a logic node pretending to be a latent node: it doesn't check that your VAE matches the model you're sampling, so the "if any" path is on you to wire correctly. And it's from an archived pack - frozen behavior, no updates coming.
Install. ComfyUI Manager (search "feidorian-ComfyNodes"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/Feidorian/feidorian-ComfyNodes
Restart ComfyUI. No dependencies, no downloads - it just uses ComfyUI's own VAE machinery, so install is the painless part of this pack.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| pixelsopt | IMAGE | — | |
| vaeopt | VAE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Latent | LATENT | — |