Dimensions Snap (C2C)
The two-integer node that prevents half your 'shape mismatch' crashes
- width
- height
Somewhere in your workflow there's a number that has to be divisible by 64, and when it isn't, the sampler dies with a shape-mismatch error that tells you nothing useful. DimensionsSnapMEC exists to kill that entire class of crash: it takes a width and height, rounds them to the nearest multiple of N (64 by default), and hands back two clean integers. That's it. It's the boring utility node that stops being boring the third time a workflow dies on a bad dimension.
The context: Wan, Flux, and SDXL all require latent dimensions divisible by 8, 16, or 64 depending on how deep their downsampling goes. A resolution like 1024×1345 isn't just awkward - it's structurally broken for the model, and the resulting error is the most common way a promising workflow turns into a 20-minute debugging session. The node's own description is refreshingly honest about it: this prevents shape-mismatch crashes at sample time.
How it works
For each dimension it snaps to the multiple with one of three directions:
- down - floor to the multiple (1024×1345 → 1024×1344).
- up - ceiling to the multiple (→ 1024×1344 as well here, but 1343 → 1344).
- nearest - round to the closest multiple.
The implementation in nodes/helpers/helpers.py is a tiny clamp + arithmetic: every result is floored at the multiple itself, so you never get a 0×0 latent. It's two INTs in, two INTs out, nothing else.
The inputs and outputs
- width / height - whatever you're about to feed a latent or conditioning node (or compute elsewhere in the graph).
- multiple - default 64, adjustable 1–256. Use 16 or 8 if your target model's requirement is looser and you want finer granularity.
- direction -
down(default),up, ornearest.
Outputs are width and height (INT). The classic wiring is: some node (an aspect preset, a sizing math node, an image's own dims) → this → EmptyLatentImage width/height.
Installing it
Part of Code2Collapse/ComfyUI-CustomNodePacks. ComfyUI Manager → search "CustomNodePacks", or:
cd ComfyUI/custom_nodes
git clone https://github.com/Code2Collapse/ComfyUI-CustomNodePacks.git
Restart ComfyUI. No dependencies, no models, no downloads - it's integer arithmetic. (Standard pack rule: don't blanket pip install -r requirements.txt over ComfyUI's bundled torch/numpy.)
Gotchas
The traps are the small kind. First, down is the default and it reduces resolution - if you snap a 720p+ image down to the nearest 64 multiple you can lose a strip of pixels, so pick nearest or up when you care about keeping resolution. Second, remember the divisibility requirement isn't the same for every model - 64 is a safe general default, but if you're being aggressive about matching native sizes (say, Wan's 832×480), a multiple of 16 gets you closer to the exact training resolution without breaking anything. And third, this node gives you numbers, not a resized image - you still have to wire them into whatever node creates the latent. Pair it with the pack's AspectPresetMEC and you have a complete "correct dimensions, every time" front end.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 10248–16384 | — |
| height | INT | 10248–16384 | — |
| multiple | INT | 641–256 | — |
| direction | COMBO | down | 3 options: nearest, down, up |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |