ImageDrawRectangleRoundedByContainer
Rounded rectangle that snaps to your image's size
- container
- IMAGE
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.radiusand the four*_cornertoggles - corner shaping.SSAAandmethod- 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 pullor 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.
Inputs (21)
| Name | Type | Default | Description |
|---|---|---|---|
| container | IMAGE | — | |
| start_x | FLOAT | 0.10 | — |
| start_y | FLOAT | 0.20 | — |
| end_x | FLOAT | 0.90 | — |
| end_y | FLOAT | 0.80 | — |
| radius | INT | 180 | — |
| outline_size | INT | 1 | — |
| outline_red | INT | 0 | — |
| outline_green | INT | 0 | — |
| outline_blue | INT | 0 | — |
| outline_alpha | FLOAT | 1.00 | — |
| fill_red | INT | 255 | — |
| fill_green | INT | 255 | — |
| fill_blue | INT | 255 | — |
| fill_alpha | FLOAT | 1.00 | — |
| top_left_corner | COMBO | 2 options: true, false | |
| top_right_corner | COMBO | 2 options: true, false | |
| bottom_right_corner | COMBO | 2 options: true, false | |
| bottom_left_corner | COMBO | 2 options: true, false | |
| SSAA | INT | 41–16 | — |
| method | COMBO | 6 options: lanczos, bicubic, hamming, bilinear, box, nearest |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |