Nodes/CMK Flow/CMK Smart Outpaint Pad
ComfyUI Node

CMK Smart Outpaint Pad

Making a canvas bigger without stretching what's already on it

By CMKFlow·Created 3 months ago·Updated a day ago· 6
CMK Smart Outpaint Pad
  • image
  • mask
  • image
  • mask
  • outpaint_on
  • diagnostic
◄width512►
◄height512►
◄outpaint_onfalse►

Outpainting starts with a boring but easy-to-botch step: put your image on a bigger canvas and mask the new area. Stretch the image to the new dimensions and you've distorted it; pad the wrong sides and the composition drifts; forget to build the mask and the sampler repaints the whole thing. CMK Smart Outpaint Pad does exactly this one job - target size in, padded image plus a mask out.

How it works

Tell it a target width and height and set outpaint_on. It compares your input's aspect ratio to the target's and pads only along the axis that needs it, split evenly on both sides - a 1:1 image going to 16:9 gains equal bars left and right. The image is padded with black (0.0) and the mask is padded with 1.0, which is what makes the new area "generate me". If you supply a mask, your mask is padded the same way and the padded strip becomes fully masked on top of whatever you had; if you don't, an all-zero mask at source size is generated for you.

Then both are resized to exactly width × height: the image with bilinear interpolation, the mask with nearest - so the mask stays crisp rather than gaining soft edges it never had.

Note the small honesty in the diagnostic: it reports Mask: Input or Mask: Generated empty depending on which path you took. Wire mask and you can see immediately whether the node used yours.

Inputs: image, width, height (both 512 by default, step 8 - keep them on multiples of 8), outpaint_on (default false), optional mask. Outputs: image, mask, outpaint_on, diagnostic.

The boolean output is a nice touch: outpaint_on comes back out unchanged, so you can wire it into a switch downstream and gate the whole outpaint branch on the same toggle.

Installing

Manager: search CMK Flow → install the CMKFlow entry → restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/CMKFlow/cmk_nodes.git cmk_nodes
python3 cmk_nodes/scripts/install_cmk_requirements.py

No models needed for this node - it's pure tensor geometry, no dependencies beyond what the pack already installs for its detection and face engines. CMK does require the Vue Nodes / Nodes 2.0 frontend setting; enable it at the same time as you restart.

What to expect

With outpaint_on off this is a passthrough: image and mask come out untouched, and the diagnostic explicitly warns "outpaint disabled". That makes it safe to leave in a chain while you're building.

The thing to understand before you use it: the image is resampled to the target size after padding, so this is a preparation step, not a preserve-original-pixels composite. If your source is 1024×1024 and you ask for 1024×1536, the padded canvas is 1536 wide and gets scaled back down - your original content ends up slightly resampled. For a lot of outpaints that's invisible; for a hard rule about keeping original pixels byte-for-byte, it isn't the right tool, and the KB's note on crop-and-stitch approaches applies.

Also, the pad amount is derived, not chosen. You can't ask for "200 pixels on the left only" - either the aspect ratio needs padding there or it doesn't. If you need asymmetric extension, do it with a canvas node and mask before this one.

Finally, the padded strip is filled with black. Black is the community default for a reason, and it's the fill the model sees as "empty", so don't be alarmed when the padded area looks like a bar until it's sampled. What matters is that the mask is 1.0 there, and it is.

CategoryCMK/Toolbox/Image

Inputs (5)

NameTypeDefaultDescription
imageIMAGE—
widthINT51264–8192—
heightINT51264–8192—
outpaint_onBOOLEANfalse—
maskoptMASK—

Outputs (4)

NameTypeDescription
imageIMAGE—
maskMASK—
outpaint_onBOOLEAN—
diagnosticCMK_DIAGNOSTIC—