Nodes/Mikey Nodes/Mosaic Expand Image (Mikey)
ComfyUI Node

Mosaic Expand Image (Mikey)

Grow the canvas and get an outpaint mask for free

By bash-j·Created 3 years ago·Updated 10 months ago· 188
Mosaic Expand Image (Mikey)
  • image
  • result_img
  • result_mask
left0
top0
right0
bottom0

Outpainting always starts with the same two chores before any actual generation happens: put the original image on a bigger canvas, and paint a mask over the new empty area so your sampler knows what's fair game to fill in. Mosaic Expand Image does both of those chores in one node - you tell it which sides to grow and by how much, and it hands back a bigger image plus the matching mask, ready to feed straight into an inpaint-style sampling pass.

How it works

You pick how far to expand on each of the four sides independently - left, top, right, bottom - and the node extends the canvas in those directions, producing a result image at the new larger size along with a mask marking exactly which pixels are the new, empty region versus the original untouched content. That's the standard shape of any outpaint prep step: original image as the unmasked region, new canvas space as the masked region, ready for a KSampler set to fill in the masked area at a high denoise strength.

One thing worth flagging plainly: the four expansion inputs only go from 0 to 5. That's a narrow range for what would normally be a pixel count, which strongly suggests these are multipliers of the image's own dimensions rather than raw pixels - expect each step to be a meaningfully large jump in canvas size, not fine-grained control. Start at the low end and check the result before assuming you need a bigger number.

The inputs and outputs that matter

  • image - the source image to expand.
  • left, top, right, bottom (INT, 0–5 each, default 0) - how far to grow the canvas in each direction, independently. Leave a side at 0 and that edge doesn't move.
  • result_img (IMAGE output) - the expanded canvas, original content placed within it.
  • result_mask (MASK output) - marks the newly added region, ready to wire straight into whatever samples the fill.

How to install it

Bundled with the rest of Mikey Nodes. ComfyUI Manager: search "Mikey Nodes," install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/bash-j/mikey_nodes

then restart. No models or extra downloads for this node specifically - it's image manipulation, not generation.

Common issues & troubleshooting

The mask by itself does nothing visible. This node only prepares the canvas and the mask - it doesn't generate anything to fill the new space. You still need a KSampler (or a dedicated outpaint sampler) downstream, set to a high denoise strength on the masked region, or you'll just get an expanded canvas with blank/garbage content sitting in the new area.

Expansion jumps further than expected. Given the 0–5 range on each side, treat these as coarse multipliers rather than pixel counts. If right=1 already grows the canvas by roughly the image's own width, that's expected behavior, not a bug - dial back rather than assuming you need to push toward the max of 5.

Visible seam where old and new content meet. This is the universal outpainting failure mode, not specific to this node: the fix is generous mask overlap into the original image's edge, some mask blur, and - if a single sampling pass leaves a hard line - a second pass at lower denoise to blend it further. Nothing about this node's output prevents that step; it's still on you downstream.

Only one edge needs expanding but the image still looks stretched or off-center. Double-check you left the sides you don't want touched at 0 - since all four directions are independent, an accidental non-zero value on an edge you meant to leave alone will grow the canvas there too.

CategoryMikey/Image

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
leftINT00–5
topINT00–5
rightINT00–5
bottomINT00–5

Outputs (2)

NameTypeDescription
result_imgIMAGE
result_maskMASK