Nodes/ComfyUI-WanVideoWrapper/WanVideo Image Resize To Closest
ComfyUI Node Runs on cloud

WanVideo Image Resize To Closest

Snap your I2V input to a resolution Wan actually likes

By kijai·Created about a year ago·Updated 3 months ago· 6,654
WanVideo Image Resize To Closest
  • image
  • image
  • width
  • height
generation_width832
generation_height480
aspect_ratio_preservation

This is the unglamorous plumbing node that saves you a headache. When you feed a reference image into Wan for image-to-video, its dimensions can't be arbitrary - video models want resolutions that fit their latent grid, and a random 1187x769 phone photo doesn't. WanVideoImageResizeToClosest takes your image and snaps it to the nearest supported resolution for a given aspect ratio and pixel budget, "according to the original code," as its description puts it. Then it hands you back the resized image and the width and height it landed on, so you can wire those numbers straight into the rest of the graph instead of guessing.

Small node, but it's the difference between a clean run and a workflow that errors on a dimension mismatch three nodes later.

How it works

You give it a target generation_width and generation_height - think of these as your intended output canvas - plus a policy for what to do with the aspect ratio. It computes the closest valid resolution that respects the model's constraints and resizes accordingly. Crucially, the width and height outputs are the actual resolved dimensions, not your requested ones, which is what you want downstream in your embeds nodes so everything agrees.

The inputs and outputs that matter

  • image - the reference you're about to animate.
  • generation_width / generation_height (defaults 832 x 480) - your target canvas. 832x480 is the standard 480p Wan working size; bump to 1280x720 for 720p if your card can take it.
  • aspect_ratio_preservation (keep_input / stretch_to_new / crop_to_new) - the one real decision. keep_input honors your image's aspect and finds the closest fit; crop_to_new forces your target ratio by cutting; stretch_to_new forces it by distorting (usually the wrong choice unless you know you want it).

Three outputs: the resized image, plus width and height as INTs. Route those two integers into whatever needs the frame size - your empty-embeds or image-embeds node - so the whole graph uses the same numbers.

How to install it

ComfyUI Manager - search ComfyUI-WanVideoWrapper, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-WanVideoWrapper
pip install -r ComfyUI-WanVideoWrapper/requirements.txt

then restart. No model downloads - this is a pure image utility.

Common issues & troubleshooting

Your subject got cropped out of frame. That's crop_to_new doing its job on an aspect mismatch. If the composition matters, switch to keep_input and let the model take your image's native ratio instead of forcing a target it doesn't fit.

The image looks squashed. You're on stretch_to_new, which distorts to hit the exact target dimensions. Almost nobody wants this on a real photo; use keep_input or crop_to_new.

Downstream node still complains about dimensions. Make sure you're feeding this node's width/height outputs into your embeds node, not re-typing your original target numbers. The whole point is that the resolved values may differ from what you asked for, and everything downstream needs the resolved ones.

CategoryWanVideoWrapper

Inputs (4)

NameTypeDefaultDescription
imageIMAGEImage to resize
generation_widthINT83264–8096Width of the image to encode
generation_heightINT48064–8096Height of the image to encode
aspect_ratio_preservationCOMBO3 options: keep_input, stretch_to_new, crop_to_new

Outputs (3)

NameTypeDescription
imageIMAGE
widthINT
heightINT