π Prepare img2vid
Get your image video-model-ready without the calculator
- image
- IMAGE
- width
- height
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.
- 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.
- It computes the largest crop that fits your chosen aspect ratio (
16:9,3:2,1:1,2:3,9:16), centered by default. Thehorizontal_offsetandvertical_offsetintegers 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. - It downsizes the crop to your chosen
resolution(480pthrough4K), 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.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | β | |
| resolution | COMBO | 720p (HD) | 5 options: 480p (SD), 720p (HD), 1080p (Full HD), 1440p (Quad HD), 2160p (4K) |
| aspect_ratio | COMBO | 16:9 (Horizontal) | 5 options: 16:9 (Horizontal), 3:2 (Horizontal), 1:1 (Square), 2:3 (Vertical), 9:16 (Vertical) |
| horizontal_offset | INT | 0-16384β16384 | β |
| vertical_offset | INT | 0-16384β16384 | β |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | β |
| width | INT | β |
| height | INT | β |