Skip to main content
ComfyUI Workflows

Add Image Input and Inpainting to a Workflow

Extend the spine into image-to-image and masked editing, wire the mask path correctly, and understand why an inpaint that ignores your mask is usually a wiring problem.

Intermediate17 minBy ToolDix Editorial

Learning objectives

  • Convert the text-to-image spine into an image-to-image graph
  • Wire a mask through encoding, sampling, and compositing
  • Choose denoise strength deliberately for each editing task
  • Diagnose the three failures specific to masked workflows

ToolDix original visual

ComfyUI practice loop
1

Frame

Name the outcome and constraints.

2

Build

Try one bounded workflow.

3

Review

Keep evidence, revise, and share.

Image-to-image and inpainting are not different workflows. They are the same spine with the latent source changed, and understanding it that way makes both of them straightforward instead of mysterious.

One substitution turns generation into editing

ToolDix original diagram
Swap the latent source; keep everything else
Text-to-image
  • Empty Latent Image
  • Resolution set by width and height
  • Denoise stays at full
  • Result is invented
Image-to-image
  • Load Image plus VAE Encode
  • Resolution comes from the input
  • Denoise decides what survives
  • Result is a variation
The sampler does not know where its latent came from. Encode with the same VAE you decode with, or you get a colour shift people blame on the prompt.

In the text-to-image spine, an Empty Latent Image node supplies a blank canvas. Replace it with two nodes — Load Image and VAE Encode — and you have image-to-image. Everything else stays exactly where it was.

The reason this works is that the sampler does not know or care where its latent came from. It denoises whatever it is given. An empty latent is pure noise, so the result is invented; an encoded image is your picture, so the result is a variation of it.

Two consequences follow immediately. First, the output resolution now comes from the input image, not from a width and height field, so an oddly sized input produces an oddly sized output. Resize deliberately before encoding. Second, the denoise setting suddenly matters, because it decides how much of your encoded image survives. At full denoise you have thrown the input away and are doing text-to-image with extra steps.

The VAE used for encoding should match the one used for decoding. Encoding with one and decoding with another produces a colour shift that people spend a long time attributing to the prompt.

The mask path is a second wire, and it is easy to drop

ToolDix original diagram
Three destinations for one mask
Into the latent
Encode for inpaint, or set a latent noise mask. Miss this and the whole image regenerates -- the classic 'mask ignored' bug.
Through the sampler
No special sampler required. The masked latent flows exactly as before.
Into the composite
Composite the decode back over the original. The encode-decode round trip alone shifts pixels everywhere.
Masks come from the mask editor, a separate black-and-white image, or a segmentation node. All three end up in the same wire.

Inpainting adds a mask, and the mask has to reach three places. Missing any of them produces a different and confusing failure.

Into the latent. A VAE Encode For Inpaint node — or a Set Latent Noise Mask node — attaches the mask to the latent so the sampler knows which region is free to change. If the mask never reaches the latent, the whole image regenerates and the mask appears to have been ignored.

Through the sampler. The masked latent flows through the sampler exactly as before. No special sampler is required.

Into the composite. After decoding, the changed region is composited back over the original. Some workflows rely on the sampler having preserved the unmasked area, which is only approximately true — the encode-decode round trip alone shifts pixels slightly. An explicit composite against the original image guarantees that the untouched area is genuinely untouched.

Where does the mask come from? Either painted directly on a loaded image in the mask editor, or generated from a separate black-and-white image, or produced by a segmentation node. All three end up in the same wire.

Strength and mask shape decide the result

ToolDix original diagram
Two settings dominate a masked edit
Low denoise inside the mask
Adjusts what is there. Retouching a texture, fixing a small artifact.
High denoise inside the mask
Replaces the contents entirely. Necessary for a different object.
Hard mask edge
No room to blend, and the seam shows. Grow slightly and feather by default.
Small masked region
Few pixels means low detail. Crop to the region, generate at full resolution, composite back.
All three classic inpainting failures -- ignored mask, visible halo, blurry patch -- are wiring or geometry problems. Prompt changes never resolve them.

Two settings dominate masked editing.

Denoise strength inside the mask. Low values adjust the existing content — good for retouching a texture or fixing a small artifact. High values replace what is inside the mask entirely — necessary when you want a different object. There is no universally right value, and the value that works for retouching a surface will not replace an object.

Mask feathering and growth. A mask drawn exactly on an object's outline gives the model no room to blend, and the seam shows. Growing the mask slightly and feathering the edge produces a join that disappears. Most graphs include mask blur or grow nodes for exactly this, and they are worth adding by default.

There is also a resolution issue worth knowing. When a masked region is small relative to the whole image, the model sees very few pixels for it and the result is low-detail. Workflows solve this by cropping to the masked region, generating at full resolution, and compositing back — often packaged as an "inpaint at full resolution" option. For faces and hands it makes an enormous difference.

The three failures specific to this graph

The mask appears ignored. The mask is not reaching the latent. Check that wire first, before touching any setting.

A visible rectangle or halo around the edit. Either the mask has hard edges and needs feathering, or the composite is missing and you are seeing the encode-decode shift across the whole frame.

The new content is blurry compared to the rest. The masked region was small; use the crop-and-composite approach.

Each of these is a wiring or geometry problem rather than a prompt problem, which is why prompt changes never resolve them.

Practice

Take one photograph and do three tasks on the same graph: restyle the whole image at moderate denoise; replace one object using a mask at high strength; and retouch a texture using the same mask at low strength.

Then repeat the object replacement twice — once with a tight hard-edged mask, once grown and feathered. Compare the seams at full resolution. The difference is the argument for making feathering a default rather than a fix.

Common mistakes

Leaving denoise at full for image-to-image. Your input is decorative and you will not understand why.

Mismatched VAEs between encode and decode. A colour shift that looks like a prompt problem.

Hard mask edges. The seam is visible and no amount of regeneration hides it.

Inpainting a small region without cropping. The model sees too few pixels and returns soft, low-detail content.

Sources and license context

These references informed the lesson. ToolDix adds its own explanation, workflow, and practice rather than reproducing source material. Every link below leaves ToolDix and opens the publisher's own site in a new tab.

Keep going

Read these next on ToolDix.

Original lessons that build on what you just read.