LLS Simple VAE Encode
Img2img encoding with the sizing logic built in
- image
- vae
- model
- clip
- latent
- width
- height
- latent_info
Stock ComfyUI's VAE Encode is four lines: image in, latent out. LLS Simple VAE Encode is that same four lines plus the sizing logic people keep messing up by hand - it resizes your image to something the model actually wants to see, encodes it, and tells you what it did. If you've ever fed a 713×921 image into a KSampler and watched the model choke, this is the node that quietly fixes that class of problem.
It's the img2img front door of the LLS pack: the thing you put between your source image and a sampler, whether you're doing straight style transfer or feeding the repair chain.
How it works
The core encode is ComfyUI's native vae.encode - no reimplementation, no magic. What the node adds is a decision layer before the encode and honest metadata after it:
- Pick a target size via
size_source:input_image(keep the source's own dimensions),custom(use yourwidth/heightwidgets), ormodel_recommended(use the detected family's native resolution - 512 for SD 1.5, 1024 for SDXL, whatever FLUX wants). - Resize according to
resize_mode:keep_aspect(fit inside the target box without distortion),crop_center(fill the box, crop the overflow),stretch(distort to fit - almost never what you want), ornone(leave as-is, just round). - Round to the model's latent alignment. This is the hidden win: the resolution gets snapped to a multiple of the family's downscale ratio (8× for SD 1.5/SDXL, 16× for FLUX) before encoding, so the latent dimensions always match what the sampler's latent math expects. The half-pixel misalignment that causes those weird vertical seams in img2img work is exactly what this step removes.
- Encode, and return the final width/height so downstream nodes know the true size.
Inputs that matter
image and vae are required - the node raises a clear error if either is missing (and with Flux, the VAE means ae.safetensors, since Flux checkpoints don't embed one). The model_family dropdown (default Auto) drives the resolution/alignment defaults; like everywhere else in this pack, Auto infers from the optional model/clip inputs if you connect them. The three knobs most people actually touch: size_source → model_recommended for the "just give me a clean latent at native res" case, resize_mode → keep_aspect (default) so nothing gets stretched, and width/height only when you want a specific output size.
Outputs
latent- feed this to any KSampler (or the LLS Simple KSampler).width/height- the actual encoded dimensions as integers, handy for wiring into resolution-aware logic downstream.latent_info- a JSON string recording the family, resize mode, source and final dimensions, and the VAE used. Diagnostic, not required, but genuinely useful the first time someone asks "why is my latent this size."
Wiring it in
Load Image → LLS Simple VAE Encode → LLS Simple KSampler → LLS Simple VAE Decode → Preview
Installing
ComfyUI Manager → search "LLS-node", or:
cd ComfyUI/custom_nodes
git clone https://github.com/Gin3601/LLS-node
Restart, find it under LLS/Image. No requirements.txt in the pack - the encode rides entirely on core ComfyUI's VAE code.
Gotchas
- VAE encode/decode is lossy and it compounds. Every round trip through the VAE softens the image a little - that's a known property of the component, not this node. Don't chain more img2img passes than you need; the KB's VAE doc makes the same point.
- Missing VAE with Flux gives you a
[LLS] Missing VAEerror naming the fix: dropae.safetensorsintoComfyUI/models/vae/. resize_mode=stretchwill deform your image. It's there for the edge cases;keep_aspectis the default because it's the right one.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| vae | VAE | — | |
| resize_mode | COMBO | keep_aspect | 4 options: keep_aspect, crop_center, stretch, none |
| size_source | COMBO | input_image | 3 options: input_image, custom, model_recommended |
| width | INT | 51264–4096 | — |
| height | INT | 51264–4096 | — |
| model_family | COMBO | Auto | 9 options: Auto, SD1.5, SD15, SDXL, SDXL_TURBO, FLUX_SCHNELL, +3 |
| modelopt | MODEL | — | |
| clipopt | CLIP | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| latent | LATENT | — |
| width | INT | — |
| height | INT | — |
| latent_info | STRING | — |