Nodes/ComfyUI Level Pixel/Cropped Ranged Size Parameters [LP]
ComfyUI Node

Cropped Ranged Size Parameters [LP]

Keeping Inpaint Crop within a min/max window

By LevelPixel·Created 2 years ago·Updated 6 months ago· 31
Cropped Ranged Size Parameters [LP]
  • mask
  • optional_context_mask
  • cropped_size_parameters
min_width832
min_height832
max_width1216
max_height1216

The last of the four sizing-parameter nodes that feed into InpaintCrop-LP's dedicated sizing pin, and the most defensive of the bunch: instead of a single target resolution or a scale-relative-to-mask approach, this one clamps the crop into a min/max window - big enough for a small mask, small enough for a huge one, and never outside the range you set either direction.

Why bother with a range instead of a target size

Checkpoints don't perform equally well at every resolution - they're trained around specific bucket sizes, and pushing well outside that range tends to degrade quality even before you factor in VRAM cost. A pure target-size approach (CroppedAspectSizeParameters-LP) tries to hit one number regardless of mask size, which can mean upscaling a tiny mask a lot to reach it. A pure free-scale approach (CroppedFreeSizeParameters-LP) tracks the mask's own size exactly, which can drift outside a sane working resolution entirely for very small or very large masks. Ranged sizing splits the difference: it lets the crop size respond to the mask, but won't let it go below min_width/min_height or above max_width/max_height no matter what.

Worth noticing: the defaults here are 832×832 for the minimum and 1216×1216 for the maximum - 832×1216 is one of SDXL's standard portrait bucket resolutions, so these aren't arbitrary numbers; they're a sensible SDXL-shaped starting range out of the box.

The inputs and outputs that matter

  • mask - the region driving the size calculation, clamped within the range below.
  • min_width / min_height - INT, default 832 each. The floor - the crop won't go smaller than this in either dimension.
  • max_width / max_height - INT, default 1216 each. The ceiling - the crop won't exceed this in either dimension.
  • optional_context_mask - an optional MASK for factoring in extra surrounding area without it being part of what's edited.
  • Output - cropped_size_parameters (CROPPEDSIZEDATA), wired into InpaintCrop-LP's sizing pin.

How to install it

ComfyUI Manager: search "ComfyUI Level Pixel" or ComfyUI-LevelPixel, install, restart - updates automatically via Manager's "Update ALL." Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/LevelPixel/ComfyUI-LevelPixel.git

Restart ComfyUI. No models, no extra dependencies.

Common issues & troubleshooting

Every crop in your batch is coming out the same size regardless of mask. If your min and max are set close together (or equal), you've effectively turned this into a fixed-size node - which might be exactly what you want, but if not, widen the gap between the min and max values to let mask size actually influence the result again.

You're running a non-SDXL model and the defaults feel wrong. The 832×1216 defaults are SDXL-shaped bucket numbers - if you're working with a model trained at different native resolutions (a different base resolution, a different aspect convention), set min_width/min_height/max_width/max_height to match that model's own comfortable range instead of leaving the SDXL defaults in place.

You want the crop to always match the mask exactly, with no clamping at all. That's a different philosophy - use CroppedFreeSizeParameters-LP for pure scale-relative-to-mask sizing with no min/max ceiling or floor.

CategoryLevelPixel/Inpaint

Inputs (6)

NameTypeDefaultDescription
maskMASK
min_widthINT8320–16384
min_heightINT8320–16384
max_widthINT12160–16384
max_heightINT12160–16384
optional_context_maskoptMASK

Outputs (1)

NameTypeDescription
cropped_size_parametersCROPPEDSIZEDATA