Nodes/chris-comfyui-nodes/PadImageSquare
ComfyUI Node

PadImageSquare

PadImageSquare just squares your image

By chrissy0·Created 2 years ago·Updated 2 years ago· 2
PadImageSquare
  • image
  • IMAGE

Somewhere in your workflow you need a square image and the one you have is 1344x768. Reach for this node. PadImageSquare is effectively the entire contents of a one-trick pack called chris-comfyui-nodes, and the name tells you everything: it takes any image and pads the shorter side with black bars until the canvas is a perfect square. No settings, no dropdowns, no color picker. One input, one output, done.

Where does that actually get used? Models that behave best at square resolution - SD 1.5's 512x512, the 1024x1024 defaults, video models that want a square first frame - plus compositing into grids or contact sheets where every tile has to match, and any downstream node that hard-requires a square IMAGE tensor. If you'd rather not think about it and just want a square, this is the no-brainer.

How it works

Under the hood it's barely fifteen lines of torch. It strips the leading batch dimension, compares height against width, then pads the shorter axis with torch.nn.functional.pad in constant mode - value 0, i.e. black - split evenly so the image stays centered. A tall image gets bars left and right; a wide one gets bars top and bottom; an already-square image passes through untouched. The output comes back as a normal ComfyUI IMAGE tensor, ready to wire anywhere an image goes.

The inputs that matter

All of them. image (IMAGE) goes in, IMAGE comes out. That's the entire contract - there's no optional input, no strength slider, nothing hidden. You can't pick the padding color, the side, or the amount. It does exactly one thing.

Installing it

Install through ComfyUI Manager by searching "chris-comfyui-nodes", or clone it manually and restart:

cd ComfyUI/custom_nodes
git clone https://github.com/chrissy0/chris-comfyui-nodes

Restart ComfyUI and it appears under the image category. No model downloads, no requirements beyond torch - which ComfyUI already ships. The install is about as clean as a custom node gets.

Where people get burned

A few honest traps, all visible in the source:

  • It's single-image only. The squeeze() call means feeding a batch of more than one image doesn't quietly do the wrong thing - it just errors. Run it on one image at a time.
  • Black, always. If downstream img2img or ControlNet is going to see those bars, black padding can leak into the result. Mask it or crop before it reaches anything that samples.
  • Square isn't divisible. 1234x1234 is a square, but latent space wants multiples of 8 - so don't feed the output straight into a VAE encode unless the padded size divides cleanly.
  • Zero community support. This pack is basically the ComfyUI example-node template with one function swapped in, and it shows. If you need options - which side, what color, how much padding - ComfyUI's own "Pad Image for Outpainting" gives you real knobs. This node exists to be boring, and that's fine.

That's the honest review: not a node you build a pack around, just a utility that either fits your exact need or it doesn't.

Categoryimage

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (1)

NameTypeDescription
IMAGEIMAGE