📐 Divisible Crop
Crop to a VAE-friendly size before you sample
- image
- 图像
- 宽
- 高
Ever load a photo into an img2img workflow and get an error about the latent size, or worse, a render with a weird black sliver on one edge? That's the VAE's downsampling stride biting you. Diffusion models encode to latents at a fixed step - 8 for SD1.5/SDXL, 16 for SD3/Flux - and if your input dimensions aren't clean multiples of that stride, the latent ends up a slightly different size than the image, and things get weird.
📐 Divisible Crop is a one-node answer: it crops the image so width and height are both divisible by the stride of whatever model you're about to run, then hands you the new dimensions so you never have to think about it again.
The one dropdown that matters: 模型
The whole node is a model-aware crop. Pick your target and it uses the right multiple:
- SD1.5 (8) / SDXL (8) - the classic 8px stride.
- SD3 (16) / Flux (16) - 16px stride for the newer transformer-based models.
- HiDream (32) - 32px, for HiDream's heavier downsampling.
- 通用安全 (64) - the "universal safe" option, and the tooltip's recommendation for tile/compat sampling where you're not sure what the downstream needs.
The default is "Flux (16)", which is a reasonable guess in 2026, but if you're still on an SDXL workflow and forget to change it you'll crop away more than you need - the multiples are nested, so a 16-divisible size is also 8-divisible, but not the reverse.
Then 裁切方式 decides where the crop bites: center crop (default, keeps the middle of the frame), top-left, or bottom-right. The node floors the dimensions down to the nearest multiple and removes the leftover pixels from whichever side you chose. For most subjects center is right; if you're cropping a person near the edge of the frame you'll want one of the anchored options.
What comes out
Three outputs: the cropped 图像, plus 宽 and 高 as INTs. Those dimension outputs are the sleeper feature - wire them into your Empty Latent or conditioning math and the rest of the graph automatically agrees with what this node just produced. If the input is already divisible, it passes straight through untouched, so you can leave it in a workflow permanently as insurance without it ever costing you pixels.
Where you'd actually put it
Anywhere an external image enters a diffusion graph: img2img from a photo, a ControlNet pass with a real reference, an upscale loop feeding tiles into a sampler, or any pipeline where an arbitrary-resolution image has to become a latent. The classic failure it prevents is the off-by-a-few-pixels mismatch that only shows up as subtle quality loss rather than a hard error - the kind that makes you blame the model when the real culprit was a 1942×1090 input going into an 8px-stride encoder.
Installing it
Comes in the Louis Use pack:
cd ComfyUI/custom_nodes
git clone https://github.com/LouisLU1997/ComfyUI-louis-use Louis_use
Or "Louis Use" via ComfyUI Manager, then restart. No dependencies beyond what ComfyUI ships.
The tradeoff to know
It crops, it never pads. That's deliberate - padding changes the aspect ratio and can fool the model - but it means you're permanently discarding a few edge pixels every run. For a 2px excess on a 1024px image that's nothing. For a photo where the edges hold content you care about, either rotate it or accept the loss; this node's job is making dimensions valid, not preserving edges.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| 模型 | COMBO | Flux (16) | 根据目标扩散模型自动选择整除倍数: SD1.5 / SDXL → 8 SD3 / Flux → 16 HiDream → 32 通用安全 → 64(兼容几乎所有模型 / 分块采样) |
| 裁切方式 | COMBO | 居中裁切 | 保留图像的哪一部分 |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| 图像 | IMAGE | — |
| 宽 | INT | — |
| 高 | INT | — |