Nodes/Allor Plugin/ImageDrawRectangleRoundedByContainer
ComfyUI Node

ImageDrawRectangleRoundedByContainer

Rounded rectangle that snaps to your image's size

By Nourepide·Created 3 years ago·Updated 2 years ago· 295
ImageDrawRectangleRoundedByContainer
  • container
  • IMAGE
start_x0.10
start_y0.20
end_x0.90
end_y0.80
radius180
outline_size1
outline_red0
outline_green0
outline_blue0
outline_alpha1.00
fill_red255
fill_green255
fill_blue255
fill_alpha1.00
top_left_corner
top_right_corner
bottom_right_corner
bottom_left_corner
SSAA4
method

Imagine the workflow: you generate a portrait, cut out the subject, and now you want a soft rounded card behind them at exactly the canvas size, so you can drop a caption or a watermark on top. Typing the pixel dimensions by hand works until you change resolution and the layout silently breaks. ImageDrawRectangleRoundedByContainer is the version of the rounded-rect that sidesteps that entirely - instead of width/height, you feed it a reference image and it sizes the canvas to match.

How it works

Mechanically it's the same drawing pipeline as ImageDrawRectangleRounded, just with the size inputs replaced by a container IMAGE input. The node reads the container's dimensions and draws a rounded rectangle onto a transparent RGBA canvas of that exact size using PIL's rounded_rectangle. Coordinates are normalized 0–1 fractions - start_x, start_y, end_x, end_y - so the box scales proportionally with whatever you feed in. You get radius (0–360) for corner roundness plus the four corner toggles (top_left_corner, top_right_corner, bottom_right_corner, bottom_left_corner) that let you round just the top, just the bottom, or any combination.

Anti-aliasing comes from SSAA (default 4): the rectangle is drawn at 4× the target size, then downsampled with your chosen method - lanczos is the quality default, nearest if you want crisp pixel edges. fill_red/green/blue + fill_alpha set the body, outline_red/green/blue, outline_alpha, and outline_size set the stroke.

Inputs that matter

  • container - any IMAGE; its dimensions become the canvas. This is the whole point of the node.
  • start_x / start_y / end_x / end_y - box position as 0–1 fractions of the container.
  • radius and the four *_corner toggles - corner shaping.
  • SSAA and method - anti-aliasing vs. speed.

It outputs a single IMAGE. Remember it's transparent outside the rectangle, so the intended path is container → this node → composite the rectangle (and whatever sits on it) over the original image.

Installing it

One install covers the whole Allor pack:

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

Then restart ComfyUI (or use ComfyUI Manager and search for Allor Plugin). First boot creates the plugin's config.json and installs rembg + onnx from requirements.txt - expect a slow first start. No model files are needed for this node.

Gotchas

  • Allor's repo was rebased to strip images from history, so old clones can break on git pull or auto-update. If update fails, delete and re-clone; the README links to the official troubleshooting docs.
  • Don't feed a multi-frame batch and expect one rectangle per frame - the node sizes off container[0], the first frame.
  • Transparent output again: composite, don't save-and-admire.

For a plain (non-rounded) box sized to a reference image, use ImageDrawRectangleByContainer; for a rounded box on a fresh canvas, use ImageDrawRectangleRounded.

Categoryimage/draw

Inputs (21)

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

Outputs (1)

NameTypeDescription
IMAGEIMAGE