ImageTransformPaddingRelative
Give your image breathing room without losing a pixel
- images
- IMAGE
Sometimes you don't want to resize an image, you want to add space around it. Maybe the sampler needs a border, maybe you're building a composite that needs a margin, maybe you're padding a canvas so a later operation has room to work. ImageTransformPaddingRelative from the Allor Plugin does exactly that: it enlarges the canvas by a fraction of the image's own dimensions and fills the new area by one of three strategies. The word "Relative" is the point - the padding scales with the image, so one setting works at any resolution.
It's part of the Allor Plugin (Nourepide/ComfyUI-Allor), the pack that keeps RGBA and batches intact through its transform family. Where the crop nodes shrink the frame, this one grows it - same philosophy, opposite direction.
How it works
The node reads the image dimensions, computes add_width = width × scale_width and add_height = height × scale_height, and passes those to the pack's absolute padding logic, which uses PyTorch's TF.pad under the hood. The scale_width (default 0.25) and scale_height (default 0.25) inputs are fractions: 0.25 adds padding equal to a quarter of the image's size along each axis. Since it's relative, a 512px image and a 2048px image both get proportionally the same border - that's the "don't redo the math when you change resolution" convenience the node exists for.
The method dropdown decides what goes in the new border:
reflect- mirror the edge pixels back into the padding. The smoothest-looking for continuous imagery, and the one that keeps gradients flowing.edge- repeat the outermost row/column of pixels. Solid-color borders, no mirroring.constant- solid fill. Defaults to black, so this is your "letterbox" option.
Batch-safe: every frame gets the same relative padding.
Inputs and outputs
images(IMAGE) - single frame or batch.scale_width(FLOAT, default 0.25, step 0.1) - horizontal padding as a fraction of width.scale_height(FLOAT, default 0.25, step 0.1) - vertical padding as a fraction of height.method-reflect,edge, orconstant.
Output: IMAGE, larger by the padding, RGBA preserved.
Installing it
Same pack, same routine: ComfyUI Manager → "Allor Plugin" → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Nourepide/ComfyUI-Allor
No model downloads for the transform family.
Where people get burned
The big one is constant being black by default - people expect white and get a black letterbox, then panic. If you need white (or any color), don't fight this node; pad to a transparent/white canvas with a composite instead, or use edge/reflect which fill from the image itself. Second, the padding is symmetric along each axis but the two axes are independent - if you leave scale_height at 0.25 while setting scale_width to 0, you get a vertical-only border, which is either what you wanted or a surprise. And remember the output is genuinely larger pixels, not a scaled-down image: downstream resolution-sensitive nodes (like samplers) will see the new, bigger dimensions.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| scale_width | FLOAT | 0.3 | — |
| scale_height | FLOAT | 0.3 | — |
| method | COMBO | 3 options: reflect, edge, constant |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |