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.
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
Frame
Name the outcome and constraints.
Build
Try one bounded workflow.
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
- Empty Latent Image
- Resolution set by width and height
- Denoise stays at full
- Result is invented
- Load Image plus VAE Encode
- Resolution comes from the input
- Denoise decides what survives
- Result is a variation
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
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
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.
- ComfyUI Workflow Templates (opens github.com in a new tab)External · github.com (MIT)
- ComfyUI (opens github.com in a new tab)External · github.com (GPL-3.0)
Keep going
Read these next on ToolDix.
Original lessons that build on what you just read.