Nodes/Allor Plugin/ImageDrawRectangleByContainer
ComfyUI Node

ImageDrawRectangleByContainer

Allor's ByContainer trick

By Nourepide·Created 3 years ago·Updated 2 years ago· 296
ImageDrawRectangleByContainer
  • container
  • IMAGE
start_x0.10
start_y0.20
end_x0.90
end_y0.80
outline_size1
outline_red0
outline_green0
outline_blue0
outline_alpha1.00
fill_red255
fill_green255
fill_blue255
fill_alpha1.00
SSAA4
method

Every once in a while you need a rectangle that is exactly the size of another image - a border to composite over a render, a frame for a caption area, a hitbox-shaped guide. That's what the "ByContainer" in this node's name means: instead of typing a width and height, you feed it a reference image (the "container") and the canvas inherits that image's dimensions. It's part of the Allor plugin, an image-processing pack from Nourepide that's basically a WAS-Node-Suite-style toolkit built to stay in tensor space.

How it works

The node draws onto a transparent RGBA canvas sized to your container image, using PIL's ImageDraw under the hood. The coordinates are normalized - start_x, start_y, end_x, end_y are all fractions of the canvas, 0 to 1, so the same values produce a proportionally identical rectangle whether your container is 512×512 or 2048×1152. Defaults are a box from (0.1, 0.2) to (0.9, 0.8), i.e. most of the frame with a bit of margin.

Where this node earns its keep is anti-aliasing. The SSAA input (default 4) renders the rectangle at 4× the final resolution, then downsamples with your chosen method (lanczos, bicubic, hamming, bilinear, box, or nearest). That's the difference between a jagged developer-art square and edges that composite cleanly. Turn SSAA down to 1 if you want speed or a deliberately hard pixel edge.

Inputs that matter

  • container - any IMAGE; its size becomes the canvas size.
  • start_x / start_y / end_x / end_y - rectangle bounds as 0–1 fractions. Defaults put the box inside the frame, not flush with it.
  • fill_red/green/blue + fill_alpha, and outline_red/green/blue + outline_alpha - the fill and stroke colors. Alpha is 0–1, colors 0–255. Set outline_size to 0 for no border.
  • SSAA and method - the anti-aliasing quality knobs above.

It returns a single IMAGE. Note it's an RGBA image: the area outside your rectangle is transparent, so wire it into a composite/overlay step rather than expecting it to replace a background. Pair it with an alpha composite node to drop the box over a render.

Installing it

Allor is one pack covering ~90 nodes, so you install it once:

cd ComfyUI/custom_nodes
git clone https://github.com/Nourepide/ComfyUI-Allor

Then restart ComfyUI. ComfyUI Manager works too - search for Allor Plugin. First launch creates a config.json in the plugin folder and installs the pack's dependencies (rembg, onnx), which is a chunky first-start; the draw/effects/filter nodes themselves need no model downloads.

Gotchas

  • The repo was rebased to strip old images from git history (roughly 344× smaller). If you cloned an old copy, git pull can fail - the README links to update troubleshooting docs, and a clean re-clone fixes it.
  • Coordinates are fractions, not pixels. It feels weird the first time you type 0.9 instead of 900, but it means one workflow works at any resolution.
  • Don't forget the output is transparent outside the rectangle; if you save it directly you get a box floating on black-and-white checkerboard, not a card.

If you don't need the container sizing and just want a rectangle on a fresh canvas, the plain ImageDrawRectangle node takes width/height inputs instead.

Categoryimage/draw

Inputs (16)

NameTypeDefaultDescription
containerIMAGE
start_xFLOAT0.10
start_yFLOAT0.20
end_xFLOAT0.90
end_yFLOAT0.80
outline_sizeINT1
outline_redINT0
outline_greenINT0
outline_blueINT0
outline_alphaFLOAT1.00
fill_redINT255
fill_greenINT255
fill_blueINT255
fill_alphaFLOAT1.00
SSAAINT41–16
methodCOMBO6 options: lanczos, bicubic, hamming, bilinear, box, nearest

Outputs (1)

NameTypeDescription
IMAGEIMAGE