凤希AI - 宽高-最大边长
Scale any image so its longest edge hits your target — then snap it to a friendly multiple
- 图片
- 输出图片
- 宽度
- 高度
- 基数
Video models are finicky about resolution. Feed them a 1047×731 image and many will silently refuse, hallucinate, or - worst case - eat your VRAM on dimensions they weren't trained for. The fix every workflow eventually needs is a "normalize this to a model-friendly size" step, and FxAiImageSizeConfig is a good one. It scales an image so its longest edge equals a target you set, then snaps the result down to a multiple of a base number - so the output lands on something a video model actually likes (divisible by 32, say).
The name says it all: it's a width/height-by-max-edge configurator. You never type width and height here - you type "make the long side 980" and it figures out the rest, preserving aspect ratio.
How it works
The scaling math is the interesting part, and it's opinionated in a good way. It takes your 最大边长 (max edge, default 980) and computes a scale factor against the image's longer dimension, resizing with Lanczos for quality. Then two guardrails:
- It refuses to upscale. If the computed size would be larger than the original, the node raises an error and stops. This is a downscale-only node, and the refusal is deliberate - silently upscaling input images is how a lot of workflows get soft, mushy results without anyone noticing.
- It aligns to a base multiple. The 对齐基数 (alignment base, default 32) floors the dimensions to a multiple of that base, then the difference is trimmed off by center-cropping. So a scaled 1000×560 with base 32 becomes 992×544-ish, cropped from the middle.
The result: same aspect ratio as the source (within one base-unit), longest edge at or under your target, and every dimension a clean multiple of the base you chose.
Inputs and outputs
- 图片 (IMAGE) - required.
- 最大边长 - target for the longer edge (64–4096).
- 对齐基数 - the multiple to snap to (2–128).
Outputs: 输出图片, 宽度, 高度, and 基数 (the base you used, passed through).
Installing it
Part of fxai-toolkit (凤希AI, MIT). Install via ComfyUI Manager (search "fxai-toolkit") or:
cd ComfyUI/custom_nodes
git clone https://github.com/fxai666/fxai-toolkit
# restart ComfyUI
No models. The pack auto-installs soundfile and psutil on first load. Chinese labels; support via the author's QQ group (775649071) and Bilibili.
Where people get burned
The downscale-only refusal trips people first: feed it a small image with 最大边长 set high and the run stops with "禁止执行缩放" (upscale forbidden). If you need to upscale, this isn't the node - pair it with a real upscaler and size after. The center-crop is the second surprise: the alignment step cuts from the middle, so if your subject sits at the edge of the frame, it can get shaved. For typical centered subjects that's invisible; for edge-weighted compositions, check the output. And note it processes a single image - for a whole batch, run it per-frame or use the pack's batch/size utilities.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| 图片 | IMAGE | — | |
| 最大边长 | INT | 98064–4096 | — |
| 对齐基数 | INT | 322–128 | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| 输出图片 | IMAGE | — |
| 宽度 | INT | — |
| 高度 | INT | — |
| 基数 | INT | — |