CopyMakeBorder
Pad an image with a border, five ways
- image
- IMAGE
Sometimes you just need to add pixels around an image. CopyMakeBorder is the pack's wrapper around OpenCV's copyMakeBorder - it grows an image by border_size pixels on all four sides, and lets you choose how those new pixels are filled. It sounds trivial, but padding matters more than you'd think: compositing, contour work (objects touching the canvas edge), tiling, and collage prep all behave better with a deliberate border.
The name is pure OpenCV heritage - "copy make border" is literally cv.copyMakeBorder.
How it works
-
image - the source
IMAGE. -
border_size - pixels added on every side (default 64).
-
border_type - the fill strategy, the whole point of the node:
- BORDER_CONSTANT (default) - solid color padding. Note there's no color input on this node, so "constant" means black. If you want a colored border, pad with constant then composite, or use a different tool.
- BORDER_REPLICATE - repeats the edge pixels outward. Great when you want a border that visually continues the image.
- BORDER_REFLECT / BORDER_REFLECT101 - mirrors the image across the edge (101 omits the edge pixel itself; it's the classic OpenCV "mirror with a seam-free center" option). Good for textures where you don't want a hard edge.
- BORDER_WRAP - wraps around, as if the image were a cylinder. Useful for seamless tiling.
- BORDER_DEFAULT / BORDER_ISOLATED - variations on the others.
Output: the padded IMAGE.
Why you'd bother
- Contour sanity. OpenCV contour-finding treats shapes touching the canvas edge awkwardly. Padding with
REPLICATE(or a constant) beforeContourskeeps blobs whole. - Tiling.
BORDER_WRAPorREFLECTpadding makes tile edges blend instead of clipping. - Compositing layouts. Add breathing room around a subject before pasting it into a collage.
- VAE/scale workflows where dimensions need to be divisible or padded for the next node.
The selection logic is simple: constant = plain solid pad (black here), replicate = stretch edges, reflect = mirror, wrap = tile-around. For 90% of mask/CV work you'll want REPLICATE or REFLECT.
Gotchas
The missing color input is the one real surprise - BORDER_CONSTANT gives you black, always, because the info schema exposes no border color. Don't assume you can pick it; if you need a colored border, pad with constant and overlay, or use a compositing node.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_bmad_nodes
cd comfyui_bmad_nodes
pip install -r requirements.txt
or install "comfyui_bmad_nodes" via ComfyUI Manager and restart. OpenCV does the work; no models. It's a boring node that quietly un-breaks a lot of CV pipelines.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| border_size | INT | 64 | — |
| border_type | COMBO | BORDER_CONSTANT | 7 options: BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT, BORDER_REFLECT101, BORDER_WRAP, BORDER_DEFAULT, +1 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |