Nodes/ComfyUI-Light-Tool/Light-Tool: Safe Image Crop
ComfyUI Node

Light-Tool: Safe Image Crop

The 10-second fix for VAE dimension errors

By ihmily·Created 2 years ago·Updated 4 months ago· 20
Light-Tool: Safe Image Crop
  • image
  • IMAGE
multiple_of64

Every once in a while ComfyUI screams at you about an image size that "cannot be divided by 8" and you realize you fed the VAE a 1021×1019 JPEG from the internet. This node is the 10-second fix: it crops any image from the center down to the nearest multiple of whatever number you pick, so the VAE never sees a dimension it can't handle.

Why the multiple matters

ComfyUI's VAE doesn't generate pixels at arbitrary sizes. It downsamples 8× per side into the latent space (that's where the magic "divisible by 8" rule comes from - see the VAE notes in the KB), and models like SD 1.5 and SDXL choke, or silently produce artifacts, when you hand them a non-multiple. 64 is the community's comfortable default because it keeps tiling and tiled-diffusion workflows clean. The node's multiple_of dropdown gives you 8, 16, 32, 64, 128, 256, 512, and 1024, with 64 preselected. For a pure SD1.5/XL latent encode, 8 is technically enough; if you plan to tile or upscale later, stay at 64.

How the crop works

It's dead simple under the hood. The node looks at your image's width and height, floors each one down to the largest multiple of your chosen number (target = (dim // multiple) * multiple), then slices out the middle: (height - target) // 2 on each side. Center crop, always. No padding, no distortion, nothing lost except a few pixels of edge.

That last sentence is the gotcha. It only ever crops - it never pads. If your image is smaller than your multiple, the node prints a warning to the console and returns the image untouched rather than erroring. And because it crops, you lose a hair of your composition from the edges. If you'd rather keep the whole image and letterbox it instead, use the pack's Scale Image in PAD mode (or its Ratio Padder node) - that's the padding path, this is the cropping path.

Installing it

It's part of ComfyUI-Light-Tool by Hmily. Easiest route: ComfyUI Manager → search "ComfyUI-Light-Tool" → Install → restart. Manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/ihmily/ComfyUI-Light-Tool
pip install -r requirements.txt
# restart ComfyUI

Pure Pillow/numpy work under the hood - no models, no keys, and it works offline.

Where people get burned

  • Expecting padding. If you load an image, crop it, and wonder where the edges went - that's the design. Want to keep every pixel? Scale Image PAD or AspectRatioPadder.
  • Forgetting it's a center crop. Your subject is framed to the bottom-right and the node eats the top-left. Crop-aware composition or a manual Crop Image first.
  • Relying on the warning. When the image is too small for the multiple, it silently passes through. That's graceful, but it means you don't get your guaranteed size - check the output, don't assume.

Otherwise: feed it any image, get back a VAE-safe image. It's one of those utility nodes you don't appreciate until the first time a workflow breaks on dimension math, and then it's permanently in your default graph.

CategoryComfyUI-Light-Tool/image/Crop

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
multiple_ofCOMBO648 options: 8, 16, 32, 64, 128, 256, +2

Outputs (1)

NameTypeDescription
IMAGEIMAGE