jz Resize And Pad
The Resize And Pad your outpainting actually wants
- image
- color_image
- image
- mask
If you've ever wanted to letterbox an image onto a bigger canvas with a padding colour that isn't white or black, you've hit the wall this node exists to remove. ComfyUI's built-in Resize And Pad Image is fine, but its padding colour is a two-option dropdown: white, or black. That's it. For the way outpainting actually works now - where you pad the canvas with a solid colour and ask an instruction model to "replace the red bars" - you need to pick the colour, and this is the version that lets you.
It's the same fit-and-centre math as the core node: min(target_width/w, target_height/h), so a small image scales up and a big one scales down to fill one dimension, and the leftover becomes the bar. Nothing fancy, and that's the point - it's a drop-in replacement that un-bottles the one knob everyone was missing.
How it works
padding_color accepts #rrggbb, #rgb, or the words black/white. Better, you can wire a solid-colour image into color_image - most usefully the fill_color output from this pack's jz Pad Calculator - and the colour is sampled from its top-left pixel, overriding the text field. That's how you keep the pad colour and the model's dimension table from drifting apart.
Two quiet details are worth knowing. First, the fit uses rounded (not truncated) dimensions and clamps each axis to a minimum of 1px, so a 4000x3 strip shoved into 512x512 doesn't collapse to a zero-height image. Second, a frame that already matches the target passes through without resampling - deliberate, because lanczos round-trips through 8-bit in ComfyUI's implementation, and re-encoding an already-correct image for nothing would quantize it.
Inputs that matter
target_width/target_height- the canvas size. Default 1024x1024.padding_color- the free colour.#000000default; ignored whencolor_imageis connected.interpolation- one of lanczos (default), area, bicubic, nearest-exact, bilinear. Here's the trade: lanczos is the sharpest but quantizes through 8-bit;areaorbicubicstay in float. If you're resizing and regenerating anyway, area is often the better call.
Outputs, and where they go
image is the padded result (an RGBA input stays RGBA, with the padding opaque - channels are preserved). The second output, mask, is the useful one: 1 = padding bar, 0 = the fitted image. Feed it into an inpaint node and you're masking exactly the region you want regenerated, no painting by hand. This pairs with the pack's jz Composite Back and jz Seam Repair nodes, which paste the original back and clean up the seams - the classic solid-colour outpaint flow, which the community converged on as the no-mask way to extend a canvas.
Install
It's part of the comfyui-jz pack:
cd ComfyUI/custom_nodes
git clone https://github.com/j-zhang19/comfyui-jz
restart ComfyUI (or use ComfyUI Manager and search "comfyui-jz"). Only requests, pillow, numpy - no models, no weights, nothing to download.
Gotchas
Two honest ones. The mask is inverted from what you might expect if you're used to inpainting masks: 1 is the bar, not the image - which is actually exactly what inpaint wants, so roll with it. And if you wire a color_image that isn't solid, it samples the top-left pixel and silently uses that; keep it clean. That's the whole list - for a node that's mostly "the built-in, but the colour isn't locked," there's pleasantly little to trip over.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| target_width | INT | 10241–16384 | — |
| target_height | INT | 10241–16384 | — |
| padding_color | STRING | #000000 | #rrggbb, #rgb, or black / white — ignored when color_image is connected |
| interpolation | COMBO | lanczos | 5 options: lanczos, area, bicubic, nearest-exact, bilinear |
| color_imageopt | IMAGE | a solid-colour image sampled at its top-left pixel — jz Pad Calculator's fill_color output; overrides padding_color when connected |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |