Nodes/ComfyUI_JosiaNodes/Josia图像缩放
ComfyUI Node

Josia图像缩放

Every resize mode you've ever wanted, in one Chinese-labeled panel

By Josia-doit·Created 6 months ago·Updated 4 days ago· 22
Josia图像缩放
  • 图像
  • 遮罩
  • 图像
  • 遮罩
  • 宽度
  • 高度
◄选择比例关►
◄边长倍数16►
◄裁剪方式中心裁剪►
◄缩放算法area►
◄📏 启用边长缩放false►
◄缩放至边最长边►
◄缩放长度1024►
◄🖼️ 启用像素缩放false►
◄像素数量(百万)1.00►
◄分辨率步数1►
◄✏️ 启用手动宽高false►
◄🔄 切换宽高false►
◄宽度1024►
◄高度1024►

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. area is a sensible downscaling default; switch to lanczos when 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.

Category⚡️JosiaNodes

Inputs (16)

NameTypeDefaultDescription
选择比例COMBO关目标宽高比。未开启任何缩放模式时,按接入图的像素面积适配该比例并裁掉多余部分;与任一缩放模式同时开启时,比例决定「输出框形状」,缩放模式决定「尺寸大小」,二者叠加生效、互不覆盖。
边长倍数COMBO16把输出宽高对齐到该倍数的整数倍(16 适配绝大多数 VAE 潜空间)。对齐规则:仅一边不合规时只裁切那一边、不做缩放(如 1536×2732 → 1536×2720);两边都不合规时以短边为基准等比缩小后再对齐。全程只裁切或缩小、绝不放大。「关」= 不限制。
裁剪方式COMBO中心裁剪原图如何贴合目标尺寸。中心/上下左右裁切=等比放大到铺满目标框后裁掉多余部分;拉伸缩放=直接拉伸变形到目标尺寸;扩展并填充白/黑/绿/蓝/灰=保留完整画面、空白处填对应纯色底板(适合图像外扩、抠像占位)。
缩放算法COMBOarea重采样滤镜。area 最快(默认,缩小首选);lanczos 质量最高但最慢;bicubic 平滑锐利;bilinear 折中;nearest-exact 不插值(像素画、遮罩请选它)。
📏 启用边长缩放BOOLEANfalse按「缩放至边」指定的那条边缩放到「缩放长度」,另一边等比跟随。若同时选了比例,则按选定比例解算宽高,而不是沿用原图比例。
缩放至边COMBO最长边让最长边还是最短边去匹配「缩放长度」(仅在边长缩放开启时生效)。
缩放长度INT102432–4096目标边长像素值,范围 32~4096(仅在边长缩放开启时生效)。
🖼️ 启用像素缩放BOOLEANfalse按「像素数量(百万)」控制总像素数(宽×高),优先级高于手动宽高与边长缩放。若同时选了比例,则按选定比例的宽高比来分配这些像素。
像素数量(百万)FLOAT1.000.01–4目标总像素(百万像素)。1.0 ≈ 100 万像素(约 1024×1024);0.25 ≈ 50 万像素。上限 4.0(仅在像素缩放开启时生效)。
分辨率步数INT11–3渐进式缩放步数:分几步逐步缩到目标尺寸。步数越多,大幅缩小时的画质越干净,但耗时更长。1 = 一步到位;仅在目标小于 200 万像素的常规缩放路径生效。
✏️ 启用手动宽高BOOLEANfalse由「宽度 / 高度」直接指定目标尺寸,比例不再参与尺寸计算(可配合「切换宽高」一键转横竖)。
🔄 切换宽高BOOLEANfalse把「宽度」「高度」两个值对调后使用,便于把横图一键改成竖图(仅手动宽高开启时生效)。
宽度INT102432–4096目标宽度像素值,范围 32~4096(仅手动宽高开启时生效;最终仍会按「边长倍数」对齐)。
高度INT102432–4096目标高度像素值,范围 32~4096(仅手动宽高开启时生效;最终仍会按「边长倍数」对齐)。
图像optIMAGE待处理图像(可选)。不接图且有尺寸设置时,输出该尺寸的纯色底板;不接图且未设尺寸时输出 1024×1024 白色图。裁剪方式选「扩展并填充XX色」时输出对应颜色。
遮罩optMASK可选遮罩,与图像同步做同样的缩放/裁切;「扩展并填充」新增的空白区域在遮罩中记为 0(透明)。

Outputs (4)

NameTypeDescription
图像IMAGE—
遮罩MASK—
宽度INT—
高度INT—