🧩 Crop Pad Advanced Krs
Outpainting without the guesswork — pad the canvas, get the mask, keep the original
- image
- IMAGE
- MASK
- IMAGE_BLENDED
This is the one node in the pack that doesn't care about Qwen at all. CropPadAdvancedKrs is a general-purpose crop-and-pad utility, and its reason to exist is outpainting: you need to grow a canvas beyond your image, and - critically - you need a mask of exactly the new region so the sampler only regenerates the extension and leaves the original pixels alone. Most pad nodes give you a padded image and make you build that mask by hand. This one hands it to you.
The three outputs are the point
- IMAGE - the padded canvas (transparent or a solid color, white by default).
- MASK - padded regions in white (255), the original image in black (0). This is the part that makes outpainting a two-node job: mask into your sampler's conditioning, and only the extension gets denoised.
- IMAGE_BLENDED - the canvas with the padding already blended toward the pad color across the boundary. It's a preview of what an inpaint pass would roughly fill, and it's genuinely handy for spotting obvious seams before you spend GPU time.
What to actually set
- use_custom_padding - the headline feature. Off, you get simple
padding_x/padding_yon every side. On, you getpadding_top/bottom/left/rightindependently - and negative values crop from that side instead of padding it. That's your crop-and-extend in one node: crop the top, pad the bottom. - fit_to_target_resolution - pads, then centers the whole result inside a
target_width×target_heightcanvas. Thescale_downoption shrinks everything to fit if your padded image would overflow the target. Ideal when you need an exact output resolution (say, a multiple-of-16 size a model wants) rather than "whatever the math lands on." - transparent_padding - overrides
pad_color, useful for compositing later. If you keep it off, pick from white/black/gray/red/green/blue/yellow. - feather_padding + feather_radius - ramps the mask edge over
feather_radiuspixels (linear or gaussian) so the inpaint boundary blends instead of snapping. With a feather, the model regenerates a soft band rather than a hard rectangle, which hides seams much better.
Why you'd pair this with an edit model
Context matters here. In 2026 the default answer for "extend this image" is Qwen Image Edit or Flux Kontext, and those re-emit the whole frame - which means the bits you didn't touch drift. Masked outpainting is the counter-move: it keeps unedited pixels bit-identical because nothing outside the mask is regenerated. So the modern crop-and-stitch pattern is: pad with this node, take its MASK, inpaint only the extension, stitch back. You get the edit model's reasoning without paying the drift tax. That's the workflow the KB's inpainting essay points to, and this node is the missing mask step.
Installation
cd ComfyUI/custom_nodes
git clone https://github.com/KursatAs/KrsNodes
Then restart ComfyUI (or search "KrsNodes" in ComfyUI Manager). No extra dependencies - just torch, PIL, numpy and scipy, all things ComfyUI already has. No model files, works with any checkpoint. It's the lowest-friction node in the pack.
Gotchas
- Feathering only matters if you're feeding MASK into an inpaint-style sampler; if you're just padding for a Qwen edit, leave it off - it'll only soften your mask and confuse a whole-frame model.
- Transparent padding writes an RGBA canvas; some downstream nodes expect RGB and will complain. If one does, it's the first thing to check.
- Cropping with negative padding past the image bounds throws an error rather than silently returning garbage - that's the node telling you to back off.
It's a small tool, but it's the one I'd grab for any outpainting chain, Qwen or not.
Inputs (17)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | The input image to crop and/or pad. | |
| padding_x | INT | 256 | Horizontal padding amount per side when not using custom padding. |
| padding_y | INT | 256 | Vertical padding amount per side when not using custom padding. |
| use_custom_padding | BOOLEAN | false | Enable custom padding for each side independently. Allows negative values for cropping. |
| padding_top | INT | 0 | Custom padding for the top side. Negative values crop from the top. |
| padding_bottom | INT | 0 | Custom padding for the bottom side. Negative values crop from the bottom. |
| padding_left | INT | 0 | Custom padding for the left side. Negative values crop from the left. |
| padding_right | INT | 0 | Custom padding for the right side. Negative values crop from the right. |
| fit_to_target_resolution | BOOLEAN | false | Fit the padded image to a target resolution by centering it within the target canvas. |
| target_width | INT | 1024 | Target width for fitting the image when fit_to_target_resolution is enabled. |
| target_height | INT | 1024 | Target height for fitting the image when fit_to_target_resolution is enabled. |
| scale_down | BOOLEAN | false | Scale down the image and padding if the total size exceeds the target resolution. |
| pad_color | COMBO | white | Color for solid padding areas when transparent_padding is disabled. |
| transparent_padding | BOOLEAN | false | Use transparent padding instead of a solid color. Overrides pad_color. |
| feather_padding | BOOLEAN | false | Apply feathering to the padding edges for smooth blending with the original image. |
| feather_radius | INT | 161–4096 | Radius of the feathering effect in pixels. |
| feather_type | COMBO | linear | Choose feathering method: linear ramp or gaussian blur. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |
| IMAGE_BLENDED | IMAGE | — |