Nodes/ComfyUI-Image-Inpainting/ImagePostprocess Inpaint
ComfyUI Node

ImagePostprocess Inpaint

A RealESRGAN wrapper with a footgun hiding in its constructor

By SherryXieYuchen·Created 2 years ago·Updated 2 years ago· 4
ImagePostprocess Inpaint
  • input_image
  • output_image
  • IMAGE
max_length1024

"ImagePostprocess Inpaint" is the pack's resolution-matching step: it makes the inpainted region come back at the same size as the crop it's replacing, and when the source was bigger than your working resolution, it does it by upscaling the generated region with RealESRGAN first. It's the node that closes the loop on "I inpainted at 768, but my original crop was 1600 wide - now what?"

This is the resolution mismatch problem the KB's inpainting essay flags as the classic "only masked" failure: crop to a small working size, inpaint, and the patch comes back at the wrong scale and looks pasted on. This node exists to fix exactly that, and it does it with the pack's chosen upscaler: RealESRGAN_x2plus.

How it works

Three inputs: input_image, output_image, and max_length (default 1024, range 512–1024, step 8). The logic is short:

  • If input_image's longest side is at or below max_length, the node is a pass-through - output_image is returned untouched.
  • If it's above max_length, the node upscales output_image 2× with the RealESRGAN model, then rescales it back down with Lanczos to match input_image's dimensions.

So input_image is the target, the thing whose size you want to match, and output_image is the content that gets scaled to fit. In the bundled workflow, input_image is the crop from INPAINT_CropImage and output_image is the color-corrected inpaint result - the node makes sure the patch is the same size as the crop before it gets composited.

The footgun

This node loads RealESRGAN_x2plus.pth the moment it's instantiated - even when it's going to be a pass-through. The model load lives in the node's constructor, not inside the "only if upscale needed" branch. So if that file isn't in ComfyUI/models/upscale_models/, the node throws an error at graph build time even for a small image that would never touch the upscaler. The README lists it as a required download, and it's not optional - it's the price of admission for this node.

# ComfyUI/models/upscale_models/RealESRGAN_x2plus.pth  <- required, no exceptions

Install

Pack install as usual - Manager → search "ComfyUI-Image-Inpainting", or:

cd ComfyUI/custom_nodes
git clone https://github.com/SherryXieYuchen/ComfyUI-Image-Inpainting
# restart ComfyUI

The upscaler loads through spandrel and runs via tiled inference with automatic tile-halving on OOM, so it's reasonably VRAM-friendly - but if your card is tight, keeping max_length sane (768–1024) and cropping before upscaling keeps the memory request modest. That's also the workflow's actual setting: 768, not the default 1024.

Categoryimage/transform

Inputs (3)

NameTypeDefaultDescription
input_imageIMAGE
output_imageIMAGE
max_lengthINT1024512–1024

Outputs (1)

NameTypeDescription
IMAGEIMAGE