Resize Images to Nearest Multiple
Nudge your images to the nearest multiple before the VAE — cheap insurance against dimension errors
- Images
- IMAGE
Diffusion models are fussy about dimensions in a way that still surprises people. SD 1.5 wants multiples of 8 in the latent space, SDXL and Flux want multiples of 64, and a 1001×1001 img2img input can blow up at the VAE with a shape error that reads like a personal insult. This node is the blunt fix: it resizes an image to the nearest multiple of a number you pick, so the VAE never sees a dimension it can't handle.
How it works
Two inputs, one output. Images is the IMAGE tensor (or batch), and multiple is a dropdown - 2, 4, 8, 16, 32, or 64, with 8 as the default. For every image in the batch it computes the nearest multiple of multiple in both dimensions - rounding up on ties - and bilinearly resamples to that size. If the image already lands on the multiple, it passes through untouched.
So a 1000×1000 image at multiple = 8 does nothing (1000 is already divisible by 8). A 1001×1001 at multiple = 8 becomes 1000×1000 (closer than 1008). A 1024×1024 at multiple = 64 stays put. The "nearest" behavior is worth appreciating: unlike a brute-force crop or a blind resize to a fixed target, this barely moves pixels that are almost right.
Why you'd reach for it
The pack's README frames it as "resize to nearest multiple to avoid model dimension issues," and that's exactly the job. It slots in right before VAE Encode in an img2img or batch pipeline - especially useful when you're processing a batch of arbitrary external images (say, loaded from a ZIP via Load ZIP, which is the obvious pairing here) that weren't generated at nice clean sizes. You get deterministic, model-safe dimensions without a whole upscale workflow.
Two honest caveats. First, it resamples - bilinear interpolation, not a crop - so it does soften pixels slightly when it has to move a dimension by a few pixels. For a pre-VAE nudge that's usually invisible; don't use it as your actual upscaler. Second, it fixes dimensions, not the deeper problem: generating way above a model's native resolution still causes the tiling and duplicated anatomy the community's been warning about for years. Think of this as the "stop the error" node, not the "magically generate at 4K" node.
Installing
Part of the same pack as everything else here:
cd ComfyUI/custom_nodes
git clone https://github.com/aixqueen/jayhuang-zip-unpack-images.git
Restart ComfyUI (or ComfyUI Manager → search jayhuang-zip-unpack-images). No models, no extra dependencies. Usual caveat for this pack: tiny single-commit repo, unknown author - this particular node is a few dozen lines of torch and easy to skim if you want to check before trusting it with your batch.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| Images | IMAGE | — | |
| multiple | COMBO | 6 options: 2, 4, 8, 16, 32, 64 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |