Nodes/Vision Prompt Assistant/Vision Prompt — Optional Reference Resize
ComfyUI Node

Vision Prompt — Optional Reference Resize

Optional Reference Resize

By elgalardi·Created 2 months ago·Updated a day ago· 3
Vision Prompt — Optional Reference Resize
  • image
  • IMAGE
  • width
  • height
◄width1440►
◄height1440►
◄upscale_methodlanczos►
◄keep_proportiontotal_pixels►
◄divisible_by32►

Every other resize node in ComfyUI assumes you gave it an image. This one is built around the case where you didn't - and that turns out to be the interesting part.

What it actually is

OptionalReferenceResize ships in Vision Prompt Assistant (elgalardi), a pack whose other nodes write prompt text for Qwen / MiniMax H3 image and video workflows. This node is the plumbing that sits before the reference-image socket on a generation node: it takes an optional image, resizes it to the resolution you want, and hands you back the image plus the exact width and height it ended up at.

The reason it exists is one line of the author's own description: a missing image produces None, not a black placeholder. If you've wired a reference into an optional IMAGE socket and then muted the Load Image, most nodes will still hand your model a 1024×1024 square of nothing, because a black image is a perfectly valid tensor. You get a reference that says "dark." This node instead emits nothing at all, and the convention in ComfyUI is that an unconnected - or null - optional input simply isn't passed to the downstream function, which then skips it (comfyui-node-plumbing.md covers this "optional equals None" rule as one of the engine facts that haven't moved in years).

So: one workflow, with references when you have them and without when you don't. That's the whole pitch, and it's a good one.

The inputs that matter

image is optional. Leave it empty and you get None, 0, 0 out - not a placeholder. The installed native TextEncodeQwenImage21 explicitly skips a None image, and the pack's H3 reference sockets are built for the same convention. Anything that requires a real image - VAEEncode, most loaders - will still error, and that's expected.

width / height are the target. Defaults are 1440×1440 and they are a pixel budget, not a box, in the default mode. Set either one to 0 and the node derives it from the source aspect ratio; set both to 0 and the target becomes the source size, so nothing gets resampled.

keep_proportion is where the behaviour actually lives, and it has four options:

  • total_pixels (default) - scales so width × height worth of pixels are preserved with the source ratio intact. 1440×1440 means "about 2 megapixels", not "square".
  • resize - fits inside the box, ratio intact, one dimension ends up smaller.
  • stretch - ignores ratio, which is almost never what you want.
  • crop - fits to the box then centre-crops to exactly width × height.

upscale_method (default lanczos) and divisible_by (default 32) go straight to ComfyUI's own comfy.utils.common_upscale, so the interpolation is identical to the core ImageScale node. Lanczos is the right default for pixels-only work (upscaling.md) - this node adds no detail and cannot hallucinate, it's a resampler. divisible_by floors the result down to a multiple, which keeps your latent off awkward fractional dimensions.

Outputs are IMAGE, width, height. The last two are the post-resize values - feed them into your empty-latent or canvas node and your generation matches your reference instead of fighting it. When no image is connected they read 0, which will break a latent node expecting a positive number, so gate that on the branch where you actually have one.

Install

Same as the rest of the pack. Search Vision Prompt Assistant in ComfyUI Manager, or:

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

Restart ComfyUI. There are no pip dependencies - the pack's pyproject.toml declares an empty dependency list - and this node downloads no models. It does declare requires-comfyui = ">=0.30.0", because the pack is written against the newer comfy_api.latest node API rather than the old NODE_CLASS_MAPPINGS style. On an older build the pack won't load at all; update ComfyUI. A modern pack with no mapping dictionaries is not broken (comfyui-ecosystem.md).

Where people get burned

None is not a bypass. Leaving this node in place and muting the upstream Load Image is the documented way to disable a reference, but the nodes behind the load may still execute. And "optional" is a property of the socket you're feeding, not a universal state - if you hand None to a node that needs pixels, you'll get a type error and a workflow that won't queue.

It is not KJ's resize. No padding, no mask handling, no GPU/VSR options - the author says so plainly. Need pad-to-fit? That's ImageResizeKJ.

Downscaling a reference is not free. If your reference is soft, resampling it to a bigger pixel budget just makes it bigger - downscale toward what the image can actually support. Same logic as the community's 0.35MP-before-SeedVR2 trick (upscaling.md).

Categoryimage/transform

Inputs (6)

NameTypeDefaultDescription
widthINT14400–16384—
heightINT14400–16384—
upscale_methodCOMBOlanczos5 options: nearest-exact, bilinear, area, bicubic, lanczos
keep_proportionCOMBOtotal_pixels4 options: total_pixels, resize, stretch, crop
divisible_byINT321–512—
imageoptIMAGE—

Outputs (3)

NameTypeDescription
IMAGEIMAGE—
widthINT—
heightINT—