Nodes/ComfyUI-TextureAlchemy/BBox Reposition ๐Ÿ“
ComfyUI Node

BBox Reposition ๐Ÿ“

Put a patched region back exactly where it belongs

By amtarrยทCreated 9 months agoยทUpdated 4 months agoยท 58
BBox Reposition ๐Ÿ“
  • image
  • base_image
  • bbox_data
  • image
  • bbox_data
  • info
โ—„positioncenterโ–บ
โ—„blend_modereplaceโ–บ

The end of every region-based inpainting workflow is the same problem: you processed a crop, and now you have to paste it back onto the original canvas at the right spot, at the right size. Do that by hand and you'll be doing math on image coordinates. BBox Reposition is the node that does the paste for you - it takes your processed image, a base canvas, and a bounding-box description, and drops the image onto the canvas at any of nine anchor positions.

It's the final stitch in the pack's inpainting story, which also includes Patch Upscale, Patch Fit, and BBox editing nodes. Where those handle scaling, this one handles placement.

How it works

It takes your small image, a full-size base_image, and a bbox_data object (the node's own BBOX_DATA type, produced by the pack's bbox-detection nodes). It computes where the image should sit on the base canvas for the chosen anchor - top_left, center, bottom_right, and every edge position in between - clamps to the canvas boundaries, and pastes. The blend_mode gives you two options:

  • replace - the pasted pixels overwrite the base. This is the one you want for stitching an inpainted region back in.
  • blend - a plain 50/50 mix of base and patch. It's a crude alpha substitute; use it when you want a soft transition and don't have a mask handy.

It also handles channel mismatches (if the patch has alpha and the base doesn't, it adds or drops channels to match) and returns an updated bbox_data reflecting the new position, plus an info string describing where it landed.

The inputs

  • image - the patch to place.
  • base_image - the canvas to paste onto.
  • bbox_data - a BBOX_DATA from a compatible node.
  • position - the nine-position anchor (default center).
  • blend_mode - replace or blend.

Outputs: image (the composited canvas), bbox_data (updated), and info (STRING).

The honest caveats

"Blend" isn't real alpha compositing - it's a hard 50/50 average, so edges will look like a ghosted double-exposure, not a feathered seam. For a clean blend you want to bring your own mask through a proper compositing node. Also, this node positions but doesn't scale: if your patch isn't already the right size for the canvas, you'll get a wrong-sized paste, which is exactly why the pack pairs it with Patch Fit - fit the size first, then position. And since it returns a new bbox, you can chain repositions, which is occasionally handy for nudging a seam into place.

Installation

Part of amtarr/ComfyUI-TextureAlchemy, under Add Node โ†’ Texture Alchemist โ†’ Inpainting. Install via ComfyUI Manager (search "TextureAlchemy") or:

cd ComfyUI/custom_nodes
git clone https://github.com/amtarr/ComfyUI-TextureAlchemy

Restart ComfyUI. No dependencies, no models - a tensor paste operation.

CategoryTexture Alchemist/Inpainting

Inputs (5)

NameTypeDefaultDescription
imageIMAGEโ€”
base_imageIMAGEโ€”
bbox_dataBBOX_DATAโ€”
positionCOMBOcenterWhere to position the image on the base canvas
blend_modeCOMBOreplaceReplace or alpha blend with base

Outputs (3)

NameTypeDescription
imageIMAGEโ€”
bbox_dataBBOX_DATAโ€”
infoSTRINGโ€”