🐳图像背景填充
Make one image exactly match another's size — no math required
- image
- reference
- image
- width
- height
Every time you've wired a "get image size" node into a "resize" node and prayed the math lined up, this node was what you actually wanted. 🐳图像背景填充 (Image Resize And Pad With Reference) resizes one image to match the exact dimensions of a reference image - and pads the difference with whatever color you like. You don't type a single resolution. You hand it two images and it sorts out the rest.
This is the original of the pair, and it's the one I reach for when I'm trying to make two things compositable: a mask generated at one resolution, a ControlNet map at another, a subject image that doesn't match the canvas you're about to inpaint on. When everything downstream expects the same dimensions, this is the funnel that gets you there.
How it works
Under the hood it reads the reference image's shape and uses those pixel dimensions as the target width and height - literally the same resize-and-pad engine as its fixed-size sibling, just with the numbers pulled from a second image instead of typed in. The resize_mode options behave identically:
- fit - scale to fit inside the reference size, pad the rest. The default, and what you usually want.
- fill - scale to cover and center-crop the overflow, leaving no padding.
- stretch - force the exact size, distorting the aspect ratio. Avoid unless you must.
- none - leave the pixels alone; pad or crop as needed.
padding_color adds the palette you expect (white, black, gray, red, green, blue) plus transparent, which is the one option this node has that the fixed version doesn't. That's for when you're building RGBA composites and want the empty space to be alpha instead of a solid fill. position anchors the resized image in one of nine spots on the canvas, and custom_color takes a hex string when you pick "custom."
Inputs and outputs
image- the image to resize.reference- the image whose dimensions become the target canvas.resize_mode,padding_color,position, optionalcustom_color.
Outputs are where this node earns its keep:
image- the resized, padded result.width,height- the reference dimensions as integers, so you can wire the numbers into other nodes (a latent resize, a math node, a text overlay) without a separate size-getter.
The transparent-padding gotcha: most of the pipeline ignores alpha. If you encode a "transparent" pad to latent and back, the empty area will come back as black or whatever the VAE does with it. Use transparent mode when you're staying in image space and feeding a compositor or a PNG saver that respects alpha - not when you're about to sample.
Install
Same as every Pond node - it's one pack:
ComfyUI Manager → search "Pond Nodes" (comfy_Pond_Nodes)
or:
cd ComfyUI/custom_nodes
git clone https://github.com/Pondowner857/comfy_Pond_Nodes
cd comfy_Pond_Nodes
pip install -r requirements.txt
Restart, and you're done. Pillow and numpy cover this node; the rest of that requirements.txt is for the pack's heavier nodes. And the usual pack warning: if your console starts spam-printing after install, that's the documented conflict with comfyui_HiDream-Sampler, not this node.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| reference | IMAGE | — | |
| resize_mode | COMBO | 4 options: fit, fill, stretch, none | |
| padding_color | COMBO | 7 options: white, black, gray, red, green, blue, +1 | |
| position | COMBO | 9 options: center, top-left, top-center, top-right, middle-left, middle-right, +3 | |
| custom_coloropt | STRING | #FFFFFF | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| width | INT | — |
| height | INT | — |