Nodes/comfyui-mudknight-utils/Load Image to Latent (full-pipe)
ComfyUI Node

Load Image to Latent (full-pipe)

Turn a loaded image into a latent, right inside the pipe

By mudknight·Created 8 months ago·Updated 2 months ago· 1
Load Image to Latent (full-pipe)
  • full_pipe
  • full_pipe
image
scalefalse
megapixels1.0

Load Image to Latent (full-pipe) does exactly what the name says: it loads an image, optionally scales it, VAE-encodes it into a latent, and packs that latent into the FULL_PIPE so the rest of your pipeline can sample on top of it. It exists to bridge the gap between "here's a photo/rendered frame" and "I want to run img2img or inpainting on it" without breaking your pipe chain.

The author's own Anima example workflow is the clearest picture of where this lives: a bypassed Load Image to Latent node sitting after the base generation. Enable it and you're suddenly doing image-to-image (no mask) or inpainting (with a mask that becomes a latent noise mask) instead of text-to-image. That's the whole trick - one node you toggle on when you want an image in the loop.

What it does

  • Loads an image with ComfyUI's built-in LoadImage, including its validation and the upload/clipspace handling. It delegates validation to LoadImage, so you can reference clipspace images and uploaded files without the node fighting you.
  • scale (off by default) + megapixels (default 1.0, 0.1–16): if you flip scale on, the image is resized to the target megapixel count while keeping aspect ratio, rounded to multiples of 8 so the VAE is happy. This is how you drag a 4K scan down to a sane generation size.
  • VAE-encodes the result and stores it in the pipe's latent field. It also keeps the image in the pipe in sync, so downstream nodes can still reference the source pixels.
  • Mask handling that matters: if the loaded image has a real alpha mask (e.g. from ComfyUI's MaskEditor), it's attached to the latent as a noise mask. LoadImage returns an all-zeros mask for a normal image, so the node checks mask.max() > 0 and only bothers when there's an actual mask - meaning you can drop a masked PNG in and go straight to inpainting.

Inputs and outputs

Required: full_pipe (needs a VAE in it - your Loader full-pipe provides that), image (the standard LoadImage file dropdown), scale, and megapixels. That's the whole form. Output: the updated full_pipe, now carrying latent and the synced image.

Installing

It's part of the mudknight utils pack. ComfyUI Manager → search comfyui-mudknight-utils, or:

cd ComfyUI/custom_nodes
git clone https://github.com/mudknight/comfyui-mudknight-utils

Restart ComfyUI. No model downloads - it uses your pipe's VAE and ComfyUI's built-in LoadImage.

Gotchas

  • The latent is in the pipe, but nothing reads it - the pipe is just a dict; a node has to actually use the latent field for it to matter. The base generation node uses it when present, and the inpainting node reads its own mask input. If your sampler ignores the loaded image, check that you're downstream of a node that consumes latent.
  • Scale looks wrong - megapixels is the total target, not a multiplier. 1.0 means ~1,048,576 pixels regardless of input aspect ratio. 4.0 gives you roughly 4MP. Expect the node to land on 8-pixel multiples, so don't expect exact dimensions.
  • Mask not sticking - the latent noise mask only attaches if the image's alpha channel is actually non-zero. A mask saved as a separate grayscale file won't be picked up by LoadImage; bake it into the image's alpha or use the MaskEditor.

Zero impressions on comfy.icu, but this is the quiet enabler of every img2img and inpaint workflow in the pack. It replaces the awkward LoadImage → VAEEncode → SetLatentNoiseMask dance with one pipe-native node.

Categorymudknight/inpainting

Inputs (4)

NameTypeDefaultDescription
full_pipeFULL_PIPE
imageCOMBO1 options: example.png
scaleBOOLEANfalse
megapixelsFLOAT1.00.1–16

Outputs (1)

NameTypeDescription
full_pipeFULL_PIPE