Nodes/CubicJ Comfy Nodes/Resize Image (Megapixels + Alignment)
ComfyUI Node

Resize Image (Megapixels + Alignment)

Resize your first frame to a megapixel budget — and keep LTX's 32-pixel rule happy

By cubicj·Created 4 months ago·Updated 3 months ago· 0
Resize Image (Megapixels + Alignment)
  • image
  • image
  • width
  • height
megapixels0.37
multiple_of32
upscale_method

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 width and height as INTs, ready to wire into EmptyLTXVLatentVideo. 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; area is 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.

Categoryimage/transform

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
megapixelsFLOAT0.370.1–4Target megapixels. 0.37 ≈ 832x448, 0.64 ≈ 1024x640
multiple_ofINT321–128Align width/height to this multiple. LTX requires 32.
upscale_methodCOMBO6 options: lanczos, bislerp, bicubic, bilinear, nearest-exact, area

Outputs (3)

NameTypeDescription
imageIMAGE
widthINT
heightINT