Josia图像缩放
Every resize mode you've ever wanted, in one Chinese-labeled panel
- 图像
- 遮罩
- 图像
- 遮罩
- 宽度
- 高度
JosiaImageScaling (Josia图像缩放) is a do-everything resize and crop node. Aspect-ratio presets, edge-based scaling, megapixel-target scaling, manual width/height, multiple-of alignment, five interpolation algorithms, six crop modes - it's a Swiss Army knife for the most common image-prep task in ComfyUI, which is "make this image a specific size that the model actually wants."
The three ways to scale
You pick one scaling strategy and the node does the rest:
- 按像素缩放 (megapixel scaling) - tell it a target in megapixels and it computes dimensions from the image's own aspect ratio. Capped at 4 megapixels, which the README flags as deliberate resolution protection so you don't blow your VRAM by asking for 20MP.
- 边长缩放 (edge scaling) - scale so the longest or shortest edge hits a target pixel value, other side follows proportionally.
- 手动宽高 (manual W/H) - just type width and height, with a one-click 切换宽高 (swap dimensions) button.
On top of that sit the four preset drop-downs (1:1 square, 2:3/3:2, 3:4/4:3, 16:9/9:16), each offering a ladder of common sizes in both orientations. Pick a preset and you don't touch the math at all.
The settings that actually change your results
- 锁定倍数 (multiple-of lock, default 8) - snaps dimensions to a multiple of 8/16/32/etc. This matters more than beginners think: VAE encode/decode and most attention layers want sizes divisible by 8, and off-by-a-few-pixel dimensions cause silent quality loss or errors.
- 缩放算法 (interpolation, default
area) - the usual ladder: nearest, bilinear, area, bicubic, lanczos.areais a sensible downscaling default; switch tolanczoswhen you're upscaling and want to keep edges crisp. - 裁剪方式 (crop mode, default center) - center, top/bottom/left/right aligned, or stretch-to-fill. This is where you control what gets cut when the source ratio doesn't match the target.
- 分辨率步数 (resolution steps) - progressive multi-step scaling for big downscales; more steps means less aliasing but slower.
Inputs and outputs
Optional 图像 (image) and 遮罩 (mask) inputs, and four outputs: 图像 (the resized IMAGE), 遮罩 (the resized MASK), and 宽度/高度 as INTs. The width/height outputs are the sleeper feature: feed no image at all and the node still hands you clean dimensions, which you can wire into an Empty Latent for a text-to-image workflow that inherits your chosen ratio. Leave every dimension setting at "off" and the image passes through untouched - it's a polite node.
Install
Part of ComfyUI_JosiaNodes, zero extra Python dependencies:
cd ComfyUI/custom_nodes
git clone https://github.com/Josia-doit/ComfyUI_JosiaNodes
or via ComfyUI Manager (search ComfyUI_JosiaNodes), then restart. Find it under Josia.
Where people get burned
The UI is entirely in Chinese - every preset and mode label reads like 16:9全平台视频, and there are fourteen boolean/enum settings stacked on the node. That's the honest downside: enormous capability, busy panel. The README is thorough but in Chinese, so keep a translation open for the first session. And remember the 4-megapixel cap: if your 8MP image comes back at 4MP, that's not a bug, that's the VRAM guard doing its job.
Inputs (16)
| Name | Type | Default | Description |
|---|---|---|---|
| 选择比例 | COMBO | 关 | 10 options: 关, 1:1 正方形, 2:3 竖屏, 3:2 横屏, 3:4 竖屏, 4:3 横屏, +4 |
| 锁定倍数 | COMBO | 16 | 8 options: 关, 2, 4, 8, 16, 32, +2 |
| 裁剪方式 | COMBO | 中心裁剪 | 6 options: 中心裁剪, 对齐上边, 对齐下边, 对齐左边, 对齐右边, 拉伸缩放 |
| 缩放算法 | COMBO | area | 5 options: nearest-exact, bilinear, area, bicubic, lanczos |
| 📏 启用边长缩放 | BOOLEAN | false | — |
| 缩放至边 | COMBO | 最长边 | 2 options: 最长边, 最短边 |
| 缩放长度 | INT | 102432–4096 | — |
| 🖼️ 启用像素缩放 | BOOLEAN | false | — |
| 像素数量(百万) | FLOAT | 1.000.01–4 | — |
| 分辨率步数 | INT | 11–3 | — |
| ✏️ 启用手动宽高 | BOOLEAN | false | — |
| 🔄 切换宽高 | BOOLEAN | false | — |
| 宽度 | INT | 102432–4096 | — |
| 高度 | INT | 102432–4096 | — |
| 图像opt | IMAGE | — | |
| 遮罩opt | MASK | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| 图像 | IMAGE | — |
| 遮罩 | MASK | — |
| 宽度 | INT | — |
| 高度 | INT | — |