Nodes/ComfyUI CogVideoX Wrapper/CogVideoXFun ResizeToClosestBucket
ComfyUI Node Runs on cloud

CogVideoXFun ResizeToClosestBucket

Size your input for the Fun models

By kijai·Created 2 years ago·Updated 12 months ago· 1,549
CogVideoXFun ResizeToClosestBucket
  • images
  • images
  • width
  • height
base_resolution512
upscale_methodlanczos
crop

A small helper with a specific job: it takes your input image (or images) and resizes them to the nearest resolution "bucket" that the CogVideoX-Fun models are happy with. The Fun line supports a range of resolutions and aspect ratios rather than one fixed size, but it does so through a set of predefined buckets - and if you feed it something off-grid, you get errors or distortion. This node snaps your input to a valid bucket and reports back the exact dimensions it chose.

Aspect-ratio bucketing is a standard trick for models trained on mixed-shape data: instead of forcing everything to a square, the model learns a handful of allowed shapes (landscape, portrait, square, and so on), and inputs get sorted into the closest one. This node is the front door for that - it makes sure whatever image you hand a Fun workflow lands on a shape the model actually understands.

The inputs and outputs that matter

  • images - the image or image batch to resize (your I2V start frame, a control sequence, whatever the Fun workflow consumes).
  • base_resolution (default 512) - the target resolution the bucket math is built around. 512 is the standard Fun base; the node figures out the matching width/height for your aspect ratio from it.
  • crop (disabled / center) - what to do when the aspect ratio doesn't match cleanly. center crops to fit the bucket exactly (you lose edges but keep proportions); disabled resizes without cropping (may squash slightly). Center crop is usually the cleaner look.
  • upscale_method (default lanczos) - the resampling filter. lanczos is the sharp, high-quality default and the right pick for most cases.

Three outputs: the resized images, plus width and height as integers. Those width/height outputs are the useful part - wire them into whatever downstream node needs to know the resolution, so your whole graph agrees on the dimensions the bucket picked.

How to install it

Comes with the wrapper:

  • ComfyUI Manager - search ComfyUI-CogVideoXWrapper, install, restart.
  • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-CogVideoXWrapper, then pip install -r ComfyUI-CogVideoXWrapper/requirements.txt, restart.

Common issues & troubleshooting

Do I need this? Only for the CogVideoX-Fun models, and mainly when your input image isn't already at a valid Fun resolution. If you're on standard CogVideoX (not Fun), or your inputs are already correctly sized, you can skip it. It's a convenience node that prevents a specific class of resolution mismatch, not a required step.

My image got cropped and I lost part of it. That's crop: center doing its job - trimming to fit the bucket's aspect ratio. Switch crop to disabled if you'd rather keep the whole frame and accept a little stretch, or pre-crop the image yourself to the target ratio before it reaches this node.

Downstream nodes disagree about resolution. Use the width and height outputs. The whole point of this node returning them is so the rest of the graph uses the bucketed dimensions, not whatever your original image was - feed those integers wherever a width/height is needed.

CategoryCogVideoWrapper

Inputs (4)

NameTypeDefaultDescription
imagesIMAGE
base_resolutionINT51264–1280Base resolution, closest training data bucket resolution is chosen based on the selection.
upscale_methodCOMBOlanczosUpscale method to use
cropCOMBO2 options: disabled, center

Outputs (3)

NameTypeDescription
imagesIMAGE
widthINT
heightINT