ComfyUI Extension: ComfyUI-JetImageScale
Run ComfyUI workflows without the setup
No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.
A ComfyUI node that scales and crops images and masks to target aspect ratios with letterboxing, cropping, stretching, and high-quality resampling filters.
Looking for a different extension?
Custom Nodes (0)
README
ComfyUI-JetImageScale
A premium ComfyUI custom node that scales and crops images and masks to target aspect ratios with support for letterboxing (with custom background color padding), cropping, and stretching.
Features
- Aspect Ratio Presets: Choose from standard aspect ratios:
original,1:1,3:2,4:3,16:9,2:3,3:4,9:16, or input acustomratio. - Custom Scaling Options: Use the
proportional_widthandproportional_heightparameters to specify any custom aspect ratio. - Sizing Boundaries: Scale to
longest,shortest,width,height, or selectnoneto preserve original scale while adjusting layout. - Three Fitting Modes:
crop: Scales the image to completely cover the target dimensions and crops excess from the center, preserving content aspect ratio.letterbox: Fits the entire image within target dimensions and pads the background with a customizable color, preserving content aspect ratio.fill: Stretches/squeezes the image to match the target dimensions exactly.
- Pillow Resampling Algorithms: Choose from high-quality resampling filters:
lanczos,bicubic,hamming,bilinear, andnearest. - Mask Alignment: Supports resizing masks alongside images, ensuring exact alignment and padding.
Input Parameters
| Parameter | Type | Default | Options / Description |
|---|---|---|---|
| image | IMAGE | Required | Input image tensor [B, H, W, C] |
| mask | MASK | Optional | Input mask tensor [B, H, W] |
| aspect_ratio | Combo | original | original, custom, 1:1, 3:2, 4:3, 16:9, 2:3, 3:4, 9:16 |
| proportional_width | INT | 1 | Proportional width multiplier for custom aspect ratio. |
| proportional_height| INT | 1 | Proportional height multiplier for custom aspect ratio. |
| fit | Combo | crop | crop, letterbox, fill |
| method | Combo | lanczos | lanczos, bicubic, hamming, bilinear, nearest |
| scale_to_side | Combo | longest | longest, shortest, width, height, none |
| scale_to_length | INT | 1280 | Dimension length to scale the selected side to. |
| background_color | STRING| #000000 | Hex color code for letterbox padding. |
Outputs
image(IMAGE): The scaled/cropped image tensor.mask(MASK): The aligned scaled/cropped mask tensor.original_size(TUPLE): The original dimensions(width, height).width(INT): The new width.height(INT): The new height.
Installation
Clone this repository into your ComfyUI custom nodes folder:
cd ComfyUI/custom_nodes
git clone https://github.com/JetterTW/ComfyUI-JetImageScale.git
ComfyUI-JetImageScale (繁體中文版)
這是一個優質的 ComfyUI 自訂節點,用於將影像與遮罩縮放、裁剪至目標寬高比。支援加黑邊(letterbox,以自訂背景顏色填滿)、裁剪(crop)以及直接拉伸填滿(fill)。
功能特點
- 寬高比預設 (Aspect Ratio Presets):可選擇標準寬高比:
original(原始)、1:1、3:2、4:3、16:9、2:3、3:4、9:16,或輸入custom(自訂) 比例。 - 自訂縮放選項 (Custom Scaling Options):使用
proportional_width與proportional_height參數指定任意自訂寬高比。 - 縮放基準邊長 (Sizing Boundaries):可縮放至
longest(最長邊)、shortest(最短邊)、width(寬度)、height(高度),或選擇none(不縮放影像內容,僅調整畫布排版)。 - 三種最適化模式 (Three Fitting Modes):
crop(裁剪):縮放影像以完全填滿目標尺寸,並從中央裁剪多餘部分,保留內容原有的寬高比。letterbox(加黑邊/信箱模式):將完整影像放入目標尺寸內,並以自訂背景顏色填滿空白處,保留內容原有的寬高比。fill(拉伸填滿):直接拉伸/壓縮影像以完全符合目標尺寸。
- Pillow 重採樣演算法 (Pillow Resampling Algorithms):提供多種高品質重採樣濾鏡:
lanczos、bicubic、hamming、bilinear與nearest。 - 遮罩對齊 (Mask Alignment):同步縮放與裁剪遮罩,確保遮罩與影像完全對齊並填滿。
輸入參數
| 參數名稱 | 類型 | 預設值 | 選項 / 說明 |
|---|---|---|---|
| image | IMAGE | 必填 | 輸入影像張量 [B, H, W, C] |
| mask | MASK | 選填 | 輸入遮罩張量 [B, H, W] |
| aspect_ratio | Combo | original | original, custom, 1:1, 3:2, 4:3, 16:9, 2:3, 3:4, 9:16 |
| proportional_width | INT | 1 | 自訂寬高比的寬度比例。 |
| proportional_height| INT | 1 | 自訂寬高比的高度比例。 |
| fit | Combo | crop | crop, letterbox, fill |
| method | Combo | lanczos | lanczos, bicubic, hamming, bilinear, nearest |
| scale_to_side | Combo | longest | longest, shortest, width, height, none |
| scale_to_length | INT | 1280 | 指定邊長縮放至的像素大小。 |
| background_color | STRING| #000000 | 信箱模式 (letterbox) 的背景填滿十六進位顏色代碼。 |
輸出
image(IMAGE):縮放/裁剪後的影像張量。mask(MASK):對齊且縮放/裁剪後的遮罩張量。original_size(TUPLE):原始尺寸(寬度, 高度)。width(INT):新寬度。height(INT):新高度。
安裝說明
將此儲存庫複製到您的 ComfyUI custom_nodes 資料夾中:
cd ComfyUI/custom_nodes
git clone https://github.com/JetterTW/ComfyUI-JetImageScale.git
Run ComfyUI workflows without the setup
No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.