ComfyUI Node

scale_and_fill_black

Shrink an image and letterbox it in black

By 438443467·Created 3 years ago·Updated about a year ago· 27
scale_and_fill_black
  • image
  • image
percentage100

Scale an image down to a percentage of its size, then center it on a black canvas that keeps the original dimensions. The result is a smaller image floating on black bars - letterboxing, in the literal sense. percentage of 100 returns the image unchanged, 50 shrinks it to half and pads the rest with black, and because the input caps at 100, this node only ever shrinks. It's a shrink-and-pad tool, not a resizer, and it's honest about that.

How it works

The image is converted to PIL, and the new dimensions are computed as width * percentage / 100. It resizes with nearest-neighbor interpolation, then creates a fresh RGB canvas at the original size filled with pure black, and pastes the shrunk image centered - x = (original_width - new_width) // 2, same for y. Anything outside the resized image is black by construction, so you always get output exactly the size you came in with. Nearest-neighbor means edges stay crisp (no blurry downscale), which matters if you're deliberately pixelating something.

Inputs and outputs

  • percentage - FLOAT, 1–100 (default 100, step 5). 100 = no change; lower = smaller image, more black border.
  • image - IMAGE.

Output: image - the letterboxed result at the original dimensions.

Where you'd actually use it

The natural use case is hitting a fixed canvas size for batch or video work: your source images are 2048×2048, your pipeline needs everything at 2048×2048 regardless of aspect, and you want black (not white or blurred) padding for the odd ones. Same idea for animating or compositing frames onto a consistent black background. If your goal is adding black space so an upscaler doesn't crop, this gets you a predictable canvas.

Two honest limits. First, since it can't exceed 100%, you can't use it to pad a smaller image up to a larger one - the original dimensions are the ceiling. Second, it's specifically black; no option for white or a color. And the pack-wide note: this node was cut in the April 2025 rewrite, so a fresh install only ships the captioner. It survives in the old Load_Image_Batch.py in git history.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/438443467/ComfyUI-GPT4V-Image-Captioner

Restart ComfyUI. No models, no dependencies.

CategorySanmi Simple Nodes/Simple NODE

Inputs (2)

NameTypeDefaultDescription
percentageFLOAT1001–100
imageIMAGE

Outputs (1)

NameTypeDescription
imageIMAGE