Resize Image (Megapixels + Alignment)
Resize your first frame to a megapixel budget — and keep LTX's 32-pixel rule happy
- image
- image
- width
- height
When you feed an image into LTX for image-to-video, there's a silent contract between three things: the input frame, the latent you're generating into, and the model's own resolution rules. If they disagree, you get weird results - conditioning that doesn't quite match the output, or a hard failure because your dimensions aren't divisible by 32. LTX-2.3 in particular just refuses off-grid sizes instead of quietly rounding. ResizeImageToMegapixels exists to make that contract hold without you doing the math.
The core idea: resize an image to a target megapixel count rather than a fixed width and height, while preserving aspect ratio and snapping the result to a multiple. It's a deceptively smart way to think about resolution for video models, because it's the area that eats VRAM, not the width. The pack's sibling node, CalculateResolution, does the same math without an image for T2V - this one operates on an actual frame.
How it works
The mechanism is simple and it uses ComfyUI's own resizer (comfy.utils.common_upscale), so it behaves like the core resize nodes you already know. It reads the image's height and width, keeps the aspect ratio, solves for the dimensions that hit your megapixel target, rounds each to the nearest multiple_of, then upscales or downscales with the method you picked. Two details make it nice:
- It skips the work when it's not needed. If the image is already at the target dims, it returns it untouched instead of resampling pointlessly.
- It hands back the numbers. You get the resized image plus
widthandheightas INTs, ready to wire intoEmptyLTXVLatentVideo. No more eyeballing "is that 832 wide?" - the node tells you exactly what it produced.
The inputs that matter
- image - the frame to resize. Usually your I2V first frame.
- megapixels - the budget. The author's tooltips are the best guide: 0.37 ≈ 832x448, 0.64 ≈ 1024x640. Start at 0.37 for LTX.
- multiple_of - alignment, default 32. The tooltip is blunt about why: "LTX requires 32."
- upscale_method - standard ComfyUI choices: lanczos, bislerp, bicubic, bilinear, nearest-exact, area. Lanczos is the safe default for upscaling;
areais the classic choice when you're shrinking.
Outputs: image, width, height.
Installing it
It's part of cubicj-comfy-nodes. In ComfyUI Manager, search "CubicJ Comfy Nodes" and install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/cubicj/cubicj-comfy-nodes
# restart ComfyUI
No dependencies, no model files. This one is pure image plumbing.
Common issues
The rounding to multiple_of means the actual output megapixels won't exactly equal your target - that's fine and expected; the divisibility matters more to LTX than the exact area. One thing to watch: the node never goes below multiple_of, so a small image with a big alignment value gets forced up. If you're downscaling and the result looks mushy, check your upscale method - area is the honest downsample, lanczos can soften when shrinking hard. And if your dimensions come back and LTX still complains, remember the other half of the constraint: frame count matters too, not just width and height.
It's worth noting this is a small, fresh pack from an individual dev - zero dependencies and readable code, but no community lore to lean on yet. The behavior is straightforward enough that you can verify it in one run.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| megapixels | FLOAT | 0.370.1–4 | Target megapixels. 0.37 ≈ 832x448, 0.64 ≈ 1024x640 |
| multiple_of | INT | 321–128 | Align width/height to this multiple. LTX requires 32. |
| upscale_method | COMBO | 6 options: lanczos, bislerp, bicubic, bilinear, nearest-exact, area |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| width | INT | — |
| height | INT | — |