Percent Padding
Grow the canvas by percent, with a feathered edge
- image
- IMAGE
Most padding nodes just add pixels in a solid color, and then you get a hard seam where the border meets your image. Percent Padding does the job with manners: it pads each side by a percentage of the image's own size, fills the border with mid-gray, and feathers the transition over roughly 32 pixels so the edge fades instead of snapping. It's the "extend the canvas so you can paint into it later" node.
It's from comfyui_davcha, the "personal QoL and experimental nodes" pack - the lighter sibling of PadAndResize, which pads and matches a latent's resolution. This one just pads.
How it works
The four floats - left, top, right, bottom - are fractions of the image's dimensions (left/right scale with width, top/bottom with height, so 0.1 left on a 1024-wide image adds 102 pixels). It pads with a constant 0.5 gray fill, then computes a distance transform on the mask so the alpha channel ramps from 0 at the outer edge to 1 inside the image over about 32 pixels. No alpha channel? One gets appended carrying that ramp; an existing alpha gets multiplied by it. The output is RGBA with a soft-edged border.
Inputs: image (IMAGE) plus the four FLOAT percentages. Output: IMAGE (RGBA).
When you'd reach for it
- Outpainting prep - pad a canvas, send the RGBA image through an encoder into an inpainting pass, and the feathered border tells the sampler where the real content ends.
- Rounded/composed edges - build a soft-edged plate to composite onto a background without a visible box.
- Aspect-ratio extension - widen an image for a format it wasn't shot at, without hard bars.
Installing it
# ComfyUI Manager → Install Custom Nodes → search "comfyui_davcha" → Install → Restart
# or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/dchatel/comfyui_davcha
cd comfyui_davcha
pip install -r requirements.txt
Standard pack catch: nodes.py imports llama_cpp and cv2 at module load while requirements.txt only lists webp and rapidfuzz. If the pack won't load, pip install llama-cpp-python opencv-python and restart.
Two things to know going in. The feather width is hardcoded to ~32 pixels - fine for most sizes, but if you're padding a tiny thumbnail, 32px is a lot of ramp, and there's no slider to shrink it. And the gray fill is fixed at 0.5 mid-gray; if your next step expects a different fill color, this isn't the node. It's a single-purpose utility, but the soft edge is what makes it worth reaching for over the stock padding nodes.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| left | FLOAT | 0.00 | — |
| top | FLOAT | 0.00 | — |
| right | FLOAT | 0.00 | — |
| bottom | FLOAT | 0.00 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |