Nodes/Allor Plugin/ImageCompositeRelativeByContainer
ComfyUI Node

ImageCompositeRelativeByContainer

Percentage-offset compositing onto a container you already have

By Nourepide·Created 3 years ago·Updated 2 years ago· 295
ImageCompositeRelativeByContainer
  • container
  • images_a
  • images_b
  • IMAGE
images_a_x0.00
images_a_y0.00
images_b_x0.00
images_b_y0.00
background
method

Take ImageCompositeRelative's percentage offsets and ImageCompositeAbsoluteByContainer's existing-canvas approach, merge them, and you get this node: two images placed onto a canvas with 0–1 offsets, where the canvas comes from an image you pass in. It's the one you reach for when the destination isn't a computed size but a concrete thing already in your graph - a pre-drawn background, a template, a frame you built with the container nodes.

How it works

It reads the container's width and height, then resolves each image's offset as (container_size - image_size) × percent - the same formula as ImageCompositeRelative. 0 pins an image to the top-left, 1 pins it to the bottom-right, 0.5 centers it. The background input chooses which of the two images sits underneath, and method is pair / matrix for batch handling.

The one hard rule: the container must be at least as large as the largest of the two images, in both dimensions, or the node raises a ValueError. The error message says it plainly ("Container can't be smaller then max width or height of images"). That's the guardrail you'll actually hit, and it usually means you fed it a container that's smaller than the content you're placing - size the container up with one of the ImageContainerInheritance* nodes first.

Inputs that matter:

  • container - the canvas; its size becomes the output size.
  • images_a / images_b - the layers.
  • images_a_x / images_a_y, images_b_x / images_b_y - 0–1 placement per axis.
  • background - stacking order.
  • method - pair or matrix.

Why you'd use it

A template workflow: draw a card or badge shape with an ImageDraw* node onto a container, then pin a generated image dead-center on it with 0.5 / 0.5 and a label in the corner with 1 / 1. The layout stays put no matter how the source images change, because everything resolves as a fraction of the container. Same RGBA reminder as the family - transparent output where nothing is placed, and offsets that push past an edge crop rather than error.

Installing Allor

Part of the Allor Plugin (Nourepide/ComfyUI-Allor), ~90 image-processing nodes from early 2024. Install once:

cd ComfyUI/custom_nodes
git clone https://github.com/Nourepide/ComfyUI-Allor
cd ComfyUI-Allor
pip install -r requirements.txt

Restart, or search "Allor Plugin" in ComfyUI Manager - the more reliable route given the pack's history of manual-install import errors (reinstall via Manager was the repeated community fix). Dependencies are rembg and onnx for the segmentation side; nothing here downloads a model.

Gotchas that apply to the whole pack

The repo was rebased to strip images from history (shrank ~344×), so git pull/auto-update can occasionally break - see the README's update-troubleshooting docs; delete-and-reclone is the blunt fix. [Allor] console lines at startup are the pack writing config.json and checking for updates, not an error.

Categoryimage/composite

Inputs (9)

NameTypeDefaultDescription
containerIMAGE
images_aIMAGE
images_bIMAGE
images_a_xFLOAT0.00
images_a_yFLOAT0.00
images_b_xFLOAT0.00
images_b_yFLOAT0.00
backgroundCOMBO2 options: images_a, images_b
methodCOMBO2 options: pair, matrix

Outputs (1)

NameTypeDescription
IMAGEIMAGE