Nodes/Comfyui_TTP_Toolset/TTP_Expand_And_Mask
ComfyUI Node Runs on cloud

TTP_Expand_And_Mask

Pad a canvas and get the outpaint mask for free

By TTPlanetPig·Created 2 years ago·Updated about a month ago· 1,030
TTP_Expand_And_Mask
  • image
  • EXPANDED_IMAGE
  • MASK
fill_modeduplicate
fill_alpha_decisionfalse
fill_color#7F7F7F
expand_leftfalse
expand_rightfalse
expand_topfalse
expand_bottomfalse
num_blocks_left1
num_blocks_right1
num_blocks_top1
num_blocks_bottom1

This one isn't documented in the pack's README at all - it's not mentioned in any of the feature sections - so everything here is read directly off what the node exposes. It's a canvas-extension helper: grow your image's edges outward and get back both the bigger image and a mask marking exactly which pixels are new, which is precisely the setup step every outpainting workflow needs before you hand it to a sampler.

Why you'd want this. Outpainting - extending an image beyond its original borders - almost always starts with this same two-step move: pad the canvas with something, then generate a mask that says "everything in the padded region is fair game, everything inside the original photo is not." The community's own version of this trick, with a plain image-pad node, is to pad each side with a flat color and prompt an edit model to "remove the padding and show what's behind it." TTP_Expand_And_Mask bundles that padding-plus-masking step into one node instead of you wiring an image-pad node and a separate mask-generation node together.

The inputs that matter. You pick which sides to grow with four booleans - expand_left, expand_right, expand_top, expand_bottom, all off by default - and how far to grow each one with matching num_blocks_left/right/top/bottom controls (0–3, default 1). fill_mode decides what goes in the new space: duplicate (repeats the edge pixels outward, a soft, blend-friendly fill) or white (a flat fill). There's also a fill_color string (default a mid-gray, #7F7F7F) and a fill_alpha_decision boolean sitting alongside the fill mode - between them they give you control over the flat-fill color and how it treats alpha, though the exact interaction with fill_mode's two named options isn't spelled out anywhere I could verify, so if you need a specific fill color, just set fill_color and check the result rather than assuming.

Outputs: EXPANDED_IMAGE (the padded canvas) and MASK (white where the new padding is, presumably black over the original image - feed this straight into an inpaint/outpaint sampler pass or an InpaintModelConditioning-style node).

Install. ComfyUI Manager, search "Comfyui_TTP_Toolset", or cd ComfyUI/custom_nodes && git clone https://github.com/TTPlanetPig/Comfyui_TTP_Toolset, then restart. Pure image manipulation - no model downloads, no extra dependencies.

Common issues. Since this node isn't in the README, there's no documented troubleshooting to lean on, so take the following as informed defaults rather than confirmed fixes. If your outpaint result has a visible seam where the original image meets the new region, try fill_mode=duplicate instead of white - a flat white or gray edge gives the sampler nothing to blend from, while duplicated edge pixels at least give it a texture gradient to work with. If you're chasing a specific final resolution and the num_blocks_* controls (capped at 3 per edge) don't get you there in one pass, run the node twice - expand, sample, expand again - rather than assuming a higher block count than the max exists.

One thing worth remembering from the wider outpainting playbook: masked outpainting (mask stays byte-identical outside the region, sampler only touches the padded area) is still the right tool when the original pixels genuinely must not drift, which is exactly what pairing this node's MASK output with a proper inpaint-conditioned sampler gets you - as opposed to a whole-frame instruction-edit model, which will happily redraw the entire image, original content included, whether you wanted that or not.

CategoryTTP/Image

Inputs (12)

NameTypeDefaultDescription
imageIMAGE
fill_modeCOMBOduplicate2 options: duplicate, white
fill_alpha_decisionBOOLEANfalse
fill_colorSTRING#7F7F7F
expand_leftoptBOOLEANfalse
expand_rightoptBOOLEANfalse
expand_topoptBOOLEANfalse
expand_bottomoptBOOLEANfalse
num_blocks_leftoptINT10–3
num_blocks_rightoptINT10–3
num_blocks_topoptINT10–3
num_blocks_bottomoptINT10–3

Outputs (2)

NameTypeDescription
EXPANDED_IMAGEIMAGE
MASKMASK