Nodes/ComfyUI-YarvixPA/πŸš€ Prepare img2vid
ComfyUI Node

πŸš€ Prepare img2vid

Get your image video-model-ready without the calculator

By YarvixPAΒ·Created about a year agoΒ·Updated 6 months agoΒ· 15
πŸš€ Prepare img2vid
  • image
  • IMAGE
  • width
  • height
β—„resolution720p (HD)β–Ί
β—„aspect_ratio16:9 (Horizontal)β–Ί
β—„horizontal_offset0β–Ί
β—„vertical_offset0β–Ί

Image-to-video models are picky in a way text-to-image never was: feed them a portrait frame at the wrong aspect ratio and you either get a crammed composition or a model that re-crops it for you, badly. This node is the "make my image fit the video model" step - it resizes, crops and reframes a still into a clean target resolution and aspect ratio, and hands back the exact width and height as integers you can wire straight into a latent loader.

It's the kind of utility you don't appreciate until you've done the mental math a few times. And because it outputs explicit width/height, it pairs neatly with video-model loaders that want real dimensions instead of guessing.

How it works

The pipeline is: upscale β†’ crop β†’ downscale.

  1. It lanczos-upscales the image so its height is 1080 - a consistent working base, so the crop math doesn't depend on your source size.
  2. It computes the largest crop that fits your chosen aspect ratio (16:9, 3:2, 1:1, 2:3, 9:16), centered by default. The horizontal_offset and vertical_offset integers pan that crop - that's the feature that keeps a subject's face in frame when a centered crop would cut it off. Offsets are clamped so you can't crop past the edge.
  3. It downsizes the crop to your chosen resolution (480p through 4K), evening out odd dimensions so latent encoders don't choke.

Outputs are the prepared IMAGE, plus width and height INTs.

Inputs

  • image - the still.
  • resolution - target height class; 720p (HD) is the default and the sensible starting point for most video models.
  • aspect_ratio - the target frame shape.
  • horizontal_offset / vertical_offset - pan the crop.

Install

Same pack as everything else: ComfyUI Manager (search "YarvixPA") or

cd ComfyUI/custom_nodes
git clone https://github.com/YarvixPA/ComfyUI-YarvixPA

restart. It's under ComfyUI-YarvixPA/Utils/Video.

Honest caveats

Two things to know before you lean on it. First, this is a resize, not a restore. The 1080-tall intermediate means a 4K output is just that base upscaled - you'll get the resolution, not the detail. For real 4K video work, feed it an already-high-res source and use it for framing, or accept 1080p. Second, aspect-ratio math is merciless on extreme sources: a tall portrait into 16:9 gets a heavy horizontal crop, and the offsets only save you so much. Check the output preview before committing a batch. For the common case - a roughly-matching still, cropped to 16:9 or 9:16 at 720p, ready for Wan or LTX - it just works.

CategoryComfyUI-YarvixPA/Utils/Video

Inputs (5)

NameTypeDefaultDescription
imageIMAGEβ€”
resolutionCOMBO720p (HD)5 options: 480p (SD), 720p (HD), 1080p (Full HD), 1440p (Quad HD), 2160p (4K)
aspect_ratioCOMBO16:9 (Horizontal)5 options: 16:9 (Horizontal), 3:2 (Horizontal), 1:1 (Square), 2:3 (Vertical), 9:16 (Vertical)
horizontal_offsetINT0-16384–16384β€”
vertical_offsetINT0-16384–16384β€”

Outputs (3)

NameTypeDescription
IMAGEIMAGEβ€”
widthINTβ€”
heightINTβ€”