Atlas Inpaint Crop ✂
Crop before you inpaint
- image
- mask
- cropped_image
- cropped_mask
- crop_region
AtlasInpaintCrop exists because of a number: 256. The LaMa inpainter inside the popular comfyui-inpaint-nodes pack squashes the entire input image to a 256×256 square, inpaints, then bilinear-upscales back. On a 4K plate that's a 16× linear downscale - which is exactly why LaMa "smears fine structure" and why everyone complains about it. This node's fix is beautifully simple: crop a padded box around the mask before the inpainter runs, so LaMa's fixed internal budget is spent on the hole's neighbourhood instead of the whole frame.
In the masking-detailing loop (detect → crop and upscale → re-render → paste back), this is the "crop and upscale" step, and it's the single biggest quality lever in the chain. A 100px hole surrounded by a little context gets a 100% effective fill budget instead of whatever 256² minus the rest of the 4K frame leaves it. The atlas-camera docs found the exact ceiling by reading the installed inpaint pack's source, which tells you how seriously this pack takes the fix.
How it works
You feed it the image and the mask (the inpaint mask, typically the output of an expand-mask node - the crop is the mask's bounding box plus padding on every side). It returns the cropped_image, the cropped_mask at the same crop, and a crop_region that carries the exact box so you can paste everything back. The crop is snapped to multiples of 64 - SD-family models want it anyway, and an unaligned crop can trip a cuDNN alignment error inside the VAE that kills the whole queue with an inscrutable "query is not correctly aligned" message.
If the mask is empty, it passes the full frame through rather than erroring - a no-op is never worse than the alternative.
The inputs
image and mask are required. Then the one slider that matters:
context_pad_px(default 128) - the quality/context tradeoff. Tight (32–64): the inpainter's fixed budget is spent almost entirely on the hole, maximum detail, but little surrounding texture to sample. Wide (256+): more context, softer fill. 128 is a good 4K-plate default, and the docs call it "THE quality slider" for a reason.
Outputs: cropped_image, cropped_mask, and the crop_region you hand to AtlasInpaintStitch.
Install and gotchas
Ships with the pack - install once, then wire it around your existing inpaint node. It needs no extra dependencies itself, but it's a pair: the actual inpainting stays in comfyui-inpaint-nodes (or any inpainter), and you close the loop with AtlasInpaintStitch. The pack's scoping rule is deliberate: it orchestrates the crop, it doesn't re-implement an inpainter.
Gotchas: multiple disjoint holes get covered by one union bounding box, so if your holes span the whole frame the crop degrades gracefully toward the full image (today's behaviour, never worse). And remember the crop is orchestration - feed the cropped image and mask into your inpainter, not the originals, or you've thrown away the whole point. Given masked inpainting still owns bit-identical compositing over edit models, and this is the quality fix for the standard LaMa path, it's worth slotting in front of every fill you do on a high-res plate.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | The inpaint mask (e.g. INPAINT_ExpandMask's output). The crop is its bounding box plus context_pad_px on every side. | |
| context_pad_pxopt | INT | 12816–2048 | THE quality slider: padding around the mask's bounding box. Tight (32-64) = the inpainter's fixed internal resolution is spent almost entirely on the hole → maximum detail, but little surrounding texture to sample. Wide (256+) = more context, softer fill. 128 is a good 4K-plate default. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| cropped_image | IMAGE | — |
| cropped_mask | MASK | — |
| crop_region | ATLAS_CROP_REGION | — |