Nodes/yiu_comfy_nodes/🖊️ Image Canvas Placer
ComfyUI Node

🖊️ Image Canvas Placer

The outpaint pad node that grows the background from the image's own edges

By leizingyiu·Created about a year ago·Updated 3 months ago· 1
🖊️ Image Canvas Placer
  • image
  • mask
  • image
  • original_mask
  • expand_mask
  • bg_image
  • edge_expand_image
  • help_text
resolution1024x1024
width_overwrite0
height_overwrite0
x_pos50.00
y_pos50.00
scale100.0
scale_ref_canvastrue
hex_color#000000
feather_radius20

Outpainting starts with a boring chore: put your image on a bigger canvas, mask the empty area, and hope the model extends it without a seam. yiuImgCnvPlacer is the boring chore turned into one node - and then it goes a step further. Instead of leaving you with a flat black pad, it grows a background from the image's own edge pixels, which is a much better starting point for the inpaint pass than a void.

This is the workhorse of the pack's outpainting use case: you have a product or a scene reference, you want a bigger canvas around it, and you want to control exactly where the original sits on that canvas. Think print layouts, e-commerce scenes, or extending a photo you like without re-generating it from scratch.

How it works

Three things happen. First, the image (and its mask, if you give one) is scaled and placed on a canvas at your chosen resolution and position - x_pos/y_pos are percentages of the remaining space, so 50/50 centers it, 100 pushes it to the right or bottom edge. Second, an expand_mask is built: a mask that's white over the empty extension area and black over the original image, with a Gaussian-feathered edge (blurred at feather_radius × 2, then level-adjusted so the soft gray shoulder becomes white). That mask is exactly what an inpaint/outpaint node wants as its mask input. Third, the clever part: edge_expand_image samples the colors along the image's border, bins them by angle, and radially interpolates them in HSV out across the canvas - so the extension looks like the image just continues, not like a colored rectangle.

The inputs that matter

  • image - the image to expand. The author's tooltip says to cut it out first (feed a transparent cutout) so the edge sampling has a real subject to work from.
  • mask - optional, but worth feeding: it gets placed alongside the image and comes back out as original_mask for inpaint-style workflows.
  • resolution - 24 SDXL/FLUX aspect-ratio presets (1024x1024, 1536x1024, etc.), overridable with width_overwrite/height_overwrite.
  • x_pos / y_pos (0–100), scale (1–100), scale_ref_canvas (true = 100% means "fit the canvas"; false = 100% means "original size").
  • hex_color and feather_radius - the solid-fill fallback color and the feather width in px.

Outputs

  • image - the placed image on a transparent canvas.
  • original_mask - the input mask, repositioned with the image.
  • expand_mask - the outpaint region mask. Wire this into your inpaint node.
  • bg_image - composite on the solid hex color.
  • edge_expand_image - composite with the radial edge-extended background. Usually the one you want to actually feed to the model.

Installing it

Part of yiu_comfy_nodes by leizingyiu. ComfyUI Manager → search yiu_comfy_nodes, or:

cd ComfyUI/custom_nodes
git clone https://github.com/leizingyiu/yiu_comfy_nodes

Restart after. No extra dependencies, no model downloads.

Where people get burned

  • Three-digit hex is rejected here. #000 errors out; the node's own parse_hex_color demands a full #RRGGBB. Its sibling yiuFitItm2Msk accepts short hex, so this inconsistency catches people who copy a color across.
  • No mask means no protection. Without an input mask, original_mask comes back all zeros, so if your inpaint passes are mask-driven you've lost your keep-region. Feed the cutout's mask.
  • Feather too big bleeds the mask. feather_radius is in pixels, not percent - 20 is a sane default; cranking it to hundreds will soften the protected zone into the extension area.
Categoryyiu_nodes

Inputs (11)

NameTypeDefaultDescription
imageIMAGE
maskMASK
resolutionCOMBO1024x102424 options: 1600x1024, 1536x1536, 1536x1024, 1344x768, 1280x768, 1152x896, +18
width_overwriteINT0
height_overwriteINT0
x_posFLOAT50.000–100
y_posFLOAT50.000–100
scaleFLOAT100.01–100
scale_ref_canvasBOOLEANtrue
hex_colorSTRING#000000
feather_radiusINT200–16384

Outputs (6)

NameTypeDescription
imageIMAGE
original_maskMASK
expand_maskMASK
bg_imageIMAGE
edge_expand_imageIMAGE
help_textSTRING