Nodes/Comfyui Krs Nodes/🧩 Crop Pad Advanced Krs
ComfyUI Node

🧩 Crop Pad Advanced Krs

Outpainting without the guesswork — pad the canvas, get the mask, keep the original

By KursatAs·Created 10 months ago·Updated 10 months ago· 0
🧩 Crop Pad Advanced Krs
  • image
  • IMAGE
  • MASK
  • IMAGE_BLENDED
â—„padding_x256â–º
â—„padding_y256â–º
â—„use_custom_paddingfalseâ–º
â—„padding_top0â–º
â—„padding_bottom0â–º
â—„padding_left0â–º
â—„padding_right0â–º
â—„fit_to_target_resolutionfalseâ–º
â—„target_width1024â–º
â—„target_height1024â–º
â—„scale_downfalseâ–º
â—„pad_colorwhiteâ–º
â—„transparent_paddingfalseâ–º
â—„feather_paddingfalseâ–º
â—„feather_radius16â–º
â—„feather_typelinearâ–º

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_y on every side. On, you get padding_top/bottom/left/right independently - 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_height canvas. The scale_down option 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_radius pixels (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.

Categoryimage/processing

Inputs (17)

NameTypeDefaultDescription
imageIMAGEThe input image to crop and/or pad.
padding_xINT256Horizontal padding amount per side when not using custom padding.
padding_yINT256Vertical padding amount per side when not using custom padding.
use_custom_paddingBOOLEANfalseEnable custom padding for each side independently. Allows negative values for cropping.
padding_topINT0Custom padding for the top side. Negative values crop from the top.
padding_bottomINT0Custom padding for the bottom side. Negative values crop from the bottom.
padding_leftINT0Custom padding for the left side. Negative values crop from the left.
padding_rightINT0Custom padding for the right side. Negative values crop from the right.
fit_to_target_resolutionBOOLEANfalseFit the padded image to a target resolution by centering it within the target canvas.
target_widthINT1024Target width for fitting the image when fit_to_target_resolution is enabled.
target_heightINT1024Target height for fitting the image when fit_to_target_resolution is enabled.
scale_downBOOLEANfalseScale down the image and padding if the total size exceeds the target resolution.
pad_colorCOMBOwhiteColor for solid padding areas when transparent_padding is disabled.
transparent_paddingBOOLEANfalseUse transparent padding instead of a solid color. Overrides pad_color.
feather_paddingBOOLEANfalseApply feathering to the padding edges for smooth blending with the original image.
feather_radiusINT161–4096Radius of the feathering effect in pixels.
feather_typeCOMBOlinearChoose feathering method: linear ramp or gaussian blur.

Outputs (3)

NameTypeDescription
IMAGEIMAGE—
MASKMASK—
IMAGE_BLENDEDIMAGE—