ComfyUI Node

Pad To Eight

The one-trick node that gets your image latent-safe

By umiyuki·Created 2 years ago·Updated 2 years ago· 0
Pad To Eight
  • image
  • image
  • width
  • height

ComfyUI is picky about image dimensions, and you'll find out the hard way the first time a sampler or latent node throws a shape error at you. Most models want their inputs to divide cleanly - SDXL trains on aspect ratios like 1152x896, Flux wants multiples of 64, and a whole layer of latent operations needs a multiple of 8. Pad To Eight is a tiny node that makes any single image play nice with that rule, in one specific way: it resizes your image to 1024px tall, then pads the width up to the nearest multiple of 8.

The name is honest about half of it. The "Pad To Eight" part is real - the "multiple of 8" behavior is what it does. What the name doesn't warn you about is that it also forces everything to 1024 height first. That's not a bug, it's the whole point, but it does mean this is a fixed-purpose tool rather than a general image-padding utility.

How it works

Under the hood it's barely a dozen lines. The node takes your IMAGE tensor, squeezes off the batch dimension, converts it to a PIL image, and then does two things:

  1. Resize to height 1024 - scales the image down (or up) with Lanczos resampling while keeping the aspect ratio.
  2. Pad width to a multiple of 8 - if the resulting width isn't divisible by 8, it pastes the image onto a white canvas a few pixels wider.

Then it converts back to a tensor and hands you the result. That's the whole mechanism. No model downloads, no API, no extra dependencies - requirements.txt is essentially empty and the code imports nothing beyond torch, PIL, and numpy, which ComfyUI already ships.

The inputs and outputs that matter

There's exactly one input and it's required:

  • image - any RGB image tensor straight out of Load Image. That's it. No sliders, no toggles.

The three outputs are what you wire downstream:

  • image - the processed image, now 1024 tall with a width divisible by 8. This is the one you feed into your VAE encode or KSampler.
  • width (INT) and height (INT) - the final dimensions, useful if you want to display them or feed them into a node that takes explicit sizes.

Install

Because the pack isn't published to the Comfy Registry (its pyproject.toml still has the placeholder your-username publisher ID), ComfyUI Manager's search may not find it. The reliable path is a plain clone:

cd ComfyUI/custom_nodes
git clone https://github.com/umiyuki/comfyui-pad-to-eight.git

Then restart ComfyUI. The pip install -r requirements.txt step in the README is optional in practice - the file is all comments. Look for Pad To Eight under the Image/Processing category in Add Node, or just search for it.

Where people get burned

The README overstates what this thing does, and the code is the truth:

  • The padding color is not configurable. The README promises "configurable padding color," but the code hardcodes white. A white strip down the right edge is what you get.
  • RGBA isn't really supported either. Despite the README, the node pastes onto an RGB canvas, so alpha gets flattened to white. A transparent PNG comes out with a white background.
  • One image at a time. The code does squeeze(0) on the batch dimension, so feeding it a batched image (batch size greater than 1) will misbehave. Hook it to a single Load Image output and you're fine.
  • The example workflow in the repo is stale boilerplate - leftover template nodes about adding numbers, not this node. Ignore it.

Should you use it?

Honestly? If you need flexible padding, KJNodes' ImagePad or Impact Pack's ImagePadForOutpaint give you actual control over amounts, colors, and sides. Reach for this one when you specifically want the "fit to 1024 height, then pad width to a multiple of 8" behavior and don't need options - for that exact case, it's the simplest thing that works. It's a narrow niche, but for a beginner trying to unblock a shape-mismatch error on a stubborn image, a one-input node that just fixes it is genuinely handy.

CategoryImage/Processing

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (3)

NameTypeDescription
imageIMAGE
widthINT
heightINT