Nodes/comfyui-timesaver/TS Studio Inpaint Crop
ComfyUI Node

TS Studio Inpaint Crop

The studio's smart crop that gives your repaint real resolution

By AlexYez·Created 2 years ago·Updated about 22 hours ago· 12
TS Studio Inpaint Crop
  • image
  • mask
  • crop
  • crop_mask
  • crop_mask_soft
  • plan
  • source
megapixels1.0
context_pct8.0
denoise1.00
snap_px64
feather_pct3.0

A repaint lives or dies by resolution. Run an inpainting sampler on the whole 8K frame and the masked region - maybe 4% of the pixels - gets 4% of the model's attention budget, which is why small fixes come back blurry. The fix is the classic one: crop the masked area, give that its own full-res pass, and paste it back. TS Studio Inpaint Crop is the crop half of that pair, built for TS Image Studio's backend workflows but perfectly usable on a plain canvas: it crops the mask with a context band, scales it to a processing budget, and hands you everything a sampler needs plus a plan for the restore step.

How it works

Feed it the full image and a painted mask (white = repaint). The node cuts out the masked region plus a context band, then scales the crop so the model spends its resolution where the mask actually is. The two proportional controls do the heavy lifting:

  • megapixels (1.0 default) - the resolution the crop is actually processed at. Small selections are enlarged toward it (up to 3x) for detail; oversized ones are reduced so a big mask in an 8K frame can't hang the machine.
  • context_pct (8) - context around the mask as a percent of the mask's own size, so it scales with the selection. More context helps the model match surroundings but shrinks the budget on the mask itself.
  • snap_px (64) - the grid the processed crop rounds up to. The VAE divides by 8/16 and transformer patches build on that, so an off-grid size costs an internal pad and a rescale on the way back. 64 is the safe general answer; for Qwen's 56-grid encoder, 112 also keeps the latent side even.
  • denoise - tells the crop how much of the masked area the sampler will replace. At full replacement the model has no pixels to anchor on, so the crop takes more context and is enlarged less - otherwise it paints a scene of its own inside the mask.
  • feather_pct - the soft edge used at paste-back time, again relative to mask size.

The outputs

  • crop + crop_mask - feed these (plus your positive/negative conditioning) to any inpainting sampler.
  • crop_mask_soft - the same mask with its soft edge kept. Feed this one when Differential Diffusion is patching the model, so the ramp becomes a per-pixel denoise schedule instead of being thrown away.
  • plan - the crop geometry plus soft edge; hand this to TS Studio Inpaint Restore along with the repainted crop.
  • source - the original frame, passed through.

The intended loop: crop → inpainting sampler → TS Studio Inpaint Restore. The restore half scales the patch back to native size, neutralizes the VAE round-trip's color shift using a preserved ring around the mask, and composites under the soft edge in linear light - which is why you get bit-exact pixels outside the mask, the thing mask-based inpainting still uniquely owns.

Install

No extra dependencies - it's part of comfyui-timesaver.

cd ComfyUI/custom_nodes
git clone https://github.com/AlexYez/comfyui-timesaver
cd comfyui-timesaver
python -m pip install -r requirements.txt

Common issues

  • "My small fix still looks soft." The crop was enlarged toward megapixels, but if megapixels is low the model still had little to work with. Raise it.
  • "It painted a new scene inside the mask." Classic full-replacement problem - denoise is at 1.0 with too little context. The node already takes more context at full denoise; bump context_pct if it's still inventing.
  • "Odd size warnings." snap_px is off the grid your model wants. 64 for most VAEs, 112 for Qwen.

The honest split: this node does the crop and planning; the sampler in the middle is still yours to choose. For the restore side, reach for TS Studio Inpaint Restore.

CategoryTS/Studio

Inputs (7)

NameTypeDefaultDescription
imageIMAGEFull source frame.
maskMASKPainted mask: white = repaint.
megapixelsFLOAT1.00.1–8Resolution the crop is actually processed at. Small selections are enlarged toward it (up to 3x) for detail; oversized ones are reduced to it so a big mask in an 8K frame cannot hang the machine.
context_pctFLOAT8.00–50How much context to take around the mask, as a percent of the mask's own size. More context helps the model match the surroundings; it also enlarges the crop, so less of the budget lands on the mask itself. Values below the 32px colour-analysis ring change nothing.
denoiseFLOAT1.000–1How much of the masked area the sampler will replace. Full replacement leaves the model no pixels to anchor on, so the crop then takes more context and is enlarged less — otherwise it paints a scene of its own inside the mask.
snap_pxINT648–256Side multiple the processed crop is rounded up to. The VAE divides by 8 or 16 and the transformer patches the latent on top of that, so a size off the grid costs an internal pad and a resize on the way back. 64 is the safe general answer; Qwen follows its own encoder on a 56 grid, where 112 also keeps the latent side even.
feather_pctFLOAT3.00–25Width of the soft edge used when the repaint is pasted back, as a percent of the mask's own size.

Outputs (5)

NameTypeDescription
cropIMAGE
crop_maskMASK
crop_mask_softMASKThe same mask with its soft edge kept. Feed this one when Differential Diffusion patches the model: it turns the ramp into a per-pixel denoise schedule instead of throwing it away.
planTS_INPAINT_PLANCrop geometry and its soft edge — feed to TS Studio Inpaint Restore.
sourceIMAGEThe frame, passed through.