Nodes/Reanimator Bridge/Fit images to a grid canvas (Reanimator)
ComfyUI Node

Fit images to a grid canvas (Reanimator)

9 keyframes quietly became 1280x736. This node is the fix.

By unluckyandlucky·Created about a month ago·Updated 11 days ago· 1
Fit images to a grid canvas (Reanimator)
  • images
  • images
  • width
  • height
◄megapixels0.90►
◄step32►

Fit images to a grid canvas (Reanimator) is a batch resizer with one job: take your images and land them on a canvas whose width and height are multiples of step, at roughly the megapixel count you asked for - while keeping the shape of your original. Then it tells you what that canvas was, as two integer outputs.

That last part is the whole reason the node exists. A resizer that only outputs images is half a tool.

Why you'd reach for it

Video models are fussy about dimensions: the latent grid wants sides divisible by 32, so nothing in your graph can honestly be 1280x720 (720 isn't a multiple of 32). The usual fix is ImageScaleToTotalPixels, and the usual fix is subtly broken for this job. It rounds each side independently, so 16:9 at ~0.9MP comes out 1280x736 - about 2.2% taller than 16:9.

For MiniMax H3 that matters more than it sounds. H3, MiniMax's 33B omni-modal video model with native stereo audio, stretches its first frame to the latent's shape but cover-crops every additional key it's given as a guide. Feed it a 1280x736 canvas of 16:9 stills and your first key fits while the rest get cropped - and the drift shows up as the shot zooming the moment it leaves key 1. Someone measured it at exactly 1.022x. That is the bug this node was written for.

So it searches instead of rounding. For every legal height it computes the nearest legal width and compares the resulting aspect ratio against yours; if any size lands within 0.5% it picks the closest in pixel count, otherwise it falls back to the closest shape. 16:9 comes out 1312x736, off by 0.3% instead of 2.2%.

Inputs that matter

Three, and you'll leave two alone.

  • images - the batch. Only the first three channels are used, so RGBA gets flattened to RGB; if you were relying on alpha, do your compositing upstream.
  • megapixels - 0.9 by default, 0.1 to 8. It's a target area, not a side length, and the shape requirement wins over the area when the two conflict. Leave it at 0.9 unless you know your card's ceiling; 24GB is roughly the entry ticket for H3 at all.
  • step - 32 by default, 8 to 128 in steps of 8. This is the multiple both sides snap to. Every H3 template ships 32 and nothing else, so 32.

Everything in the batch is cropped and scaled once, at the same centre and scale, so no key gets framed differently from another. Bad news if you threw a 4:3 frame into a 16:9 batch - it gets cropped hardest.

Outputs are images, width, height. Wire images into whatever needs a matching batch (in the keyframe graph, that's ReanimatorH3Sequencer plus an ImageFromBatch for key 1) and wire width/height into the video node's width and height. Skip that last step and you're back where you started: a perfectly shaped batch and a latent built from numbers you typed by hand.

Installing it

These three nodes ship inside comfyui-reanimator, which is really the Reanimator Bridge - software for running reanimator.app generations on your own GPU. The nodes exist as a side effect (templates can't chain a variable number of nodes), but they load and work on their own. You never have to pair a browser to use this one: it's comfy.utils.common_upscale and nothing else.

ComfyUI Manager didn't list the pack when the README was written (pending registry review), so:

cd ComfyUI/custom_nodes
git clone https://github.com/unluckyandlucky/comfyui-reanimator
pip install cryptography Pillow

The two dependencies come from the pack's pyproject.toml and are for the bridge, not this node. Or grab the ZIP, drag the comfyui-reanimator-main folder into custom_nodes, restart. Don't use Windows' Extract All - it nests the folder one level too deep and ComfyUI won't see it. Then find the node under the Reanimator category.

Where people get burned

"Fit" is doing some lying. It does not pad or letterbox. It scales to fill and centre-crops the overflow, so a taller-than-target batch loses its top and bottom. If you actually want bars added, this isn't the node.

The output video doesn't match the stills. Nine times out of ten the width/height outputs are dangling. They're the deliverable as much as the images are.

Upscaling surprise. megapixels: 2 on 16:9 is 1984x1120 of latent sampled per key. The area you pick is the area you pay for.

Nothing here breaks on an old ComfyUI. If this node fails to appear, it's the install, not a missing ComfyUI feature - unlike its two siblings in the pack, it has no dependency on ComfyUI's built-in MiniMax H3 support.

CategoryReanimator

Inputs (3)

NameTypeDefaultDescription
imagesIMAGE—
megapixelsFLOAT0.900.1–8—
stepINT328–128—

Outputs (3)

NameTypeDescription
imagesIMAGE—
widthINT—
heightINT—