🖼️AGSoft Load Image & Mask Resize (legacy)
The resize node that keeps your mask honest
- input_image
- mask
- image
- mask
- width
- height
- filename
- filepath
Every ComfyUI user hits the same wall eventually: you resize an image, and suddenly the mask you lovingly painted is useless because it no longer lines up. AGSoft Image & Mask Resize Plus is the pack's answer to that - one node that resizes the image and the mask in the same pass, so they can't drift apart. It's the most complete resize utility in comfyui-AGSoft, and the one worth grabbing first.
What makes it "Plus" over the plain Image & Mask Resize is breadth. You get five ways to state the target size, three fit strategies, six interpolation methods, plus rounding, positioning, and pad color controls. Most of the time you'll touch maybe three of those.
The inputs that actually matter
- resize_mode - the boss switch.
target_megapixels(say 1.0 to land near 1000×1000),target_percentage(50 = half, 200 = double),target_widthortarget_height(the other side is computed to keep proportions), ortarget_bothfor explicit W and H. - fit_mode - what to do when the target doesn't match the source aspect ratio:
stretch(distorts),crop(keeps proportions, cuts the excess), orpad(keeps everything, fills the rest with a color). The tooltips spell this out, andcrop_positiondecides which part survives the crop. - divisible_by - rounds the final dimensions up to a multiple. Set 8 for SD1.5, 64 for SDXL, and you'll stop getting "latent size not divisible by 64" errors at the sampler. This single field is why I reach for this node over a bare PIL resize.
- interpolation - defaults to
lanczos, which is right for final renders.areais the one to pick when downscaling;nearestif you're building pixel art and want it to stay chunky.
Optional inputs add invert_mask (handy when your mask is stored inverted) and a device choice that defaults to CPU - resizing is cheap, leave it there unless you're hammering batches.
What comes out
image and mask resized in lockstep, width/height ints you can feed into latent math, and - the sleeper hit - filename and filepath strings from the Load Image input. That makes the node genuinely useful in auto-save or workflow-logging setups that want to know where the source file lives.
How it works
Nothing exotic under the hood: it's the same PIL/torch resize machinery ComfyUI already ships, wrapped so the mask goes through the exact same geometry as the image (with nearest-neighbor resampling on the mask, so your sharp mask edges stay sharp instead of smearing into grayscale mush). The value is orchestration, not math - you get one place to set size, fit, rounding, and color, and everything downstream agrees with itself.
Installing it
Same story as every node in this pack. Easiest: ComfyUI Manager → search comfyui-AGSoft → install, restart. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/Art-xmaster/comfyui-AGSoft.git
# restart ComfyUI
No models to download, and no heavy Python deps for this node - the pack's only real requirement is translators (used by the Translate node), everything else runs on ComfyUI's built-ins. The whole pack is MIT licensed.
Common issues
The classic failure isn't the node's fault - it's forgetting divisible_by and feeding a 1027×1027 latent to an SDXL sampler. If your resized mask ever looks soft-edged, that's the interpolation default at work on the image side; the mask itself is resampled nearest, so blur there means your source mask was already blurry. And if the node is missing entirely after install, check the console: this pack loads its modules dynamically and skips any that fail, logging an [AGSoft] error line - usually a missing dependency, not a broken pack.
One honest caveat: if your workflow only resizes images and never touches masks, this is more node than you need. AGSoft Img Res MP or the plain resize will do. But the moment masks enter the picture, this is the one I reach for.
Inputs (22)
| Name | Type | Default | Description |
|---|---|---|---|
| custom_path | STRING | Optional: absolute path to an image (or a linked string). Priority: input_image > custom_path > image combo. The native preview follows it (live when typed, after execution when linked). --- Опционально: абсолютный путь к изображению (или линк со строкой). Приоритет: input_image > custom_path > комбо image. Нативное превью следует за ним (живо при вводе, после выполнения — если линком). | |
| image | COMBO | Select / upload an image from the input directory (used when input_image is not connected). --- Выберите / загрузите изображение из папки input (используется, если не подключён input_image). | |
| resize_mode | COMBO | target_percentage | Size mode: percentage / megapixels / width / height / both / longest / shortest. --- Режим размеров: проценты / мегапиксели / ширина / высота / оба / longest / shortest. |
| target_percentage | FLOAT | 100.00–1000 | Target size as % of original (100=same, 50=half, 200=double). --- Целевой размер в % от исходного (100=тот же, 50=половина, 200=двойной). |
| target_megapixels | FLOAT | 1.00.1–100 | Target megapixels (MP). Used in target_megapixels mode. --- Целевые мегапиксели (MP). Используется в режиме target_megapixels. |
| target_width | INT | 10241–8192 | Target width (px). Also = the side for longest/shortest modes. --- Целевая ширина (px). Также = сторона для longest/shortest. |
| target_height | INT | 10241–8192 | Target height (px). --- Целевая высота (px). |
| fit_mode | COMBO | crop | Scaling strategy: stretch (distort to exact target) / crop (proportional cover + cut) / pad (proportional contain + bars) / proportional (proportional fit inside the target, output = resulting size, no bars, no crop). --- Стратегия: stretch (искажить в точную цель) / crop (пропорционально закрыть и обрезать) / pad (пропорционально вписать с полями) / proportional (пропорционально вписать в цель, выход = получившийся размер, без полей и обрезки). |
| crop_position | COMBO | center | Anchor for crop/pad (9 positions). --- Якорь для crop/pad (9 позиций). |
| interpolation | COMBO | lanczos | Interpolation. RGBA auto-uses premultiplied alpha. --- Интерполяция. RGBA автоматически с premultiplied alpha. |
| resize_if_larger | COMBO | none | Pure trigger: resize ONLY if the image is LARGER than target; otherwise the original size is kept. Triggered → resize per fit_mode. none = always resize. --- Чистый триггер: ресайз ТОЛЬКО если изображение БОЛЬШЕ цели, иначе сохраняется исходный размер. Сработало → ресайз по fit_mode. none = ресайз всегда. |
| resize_if_smaller | COMBO | none | Pure trigger: resize ONLY if the image is SMALLER than target; otherwise the original size is kept. Triggered → resize per fit_mode. none = off. --- Чистый триггер: ресайз ТОЛЬКО если изображение МЕНЬШЕ цели, иначе сохраняется исходный размер. Сработало → ресайз по fit_mode. none = выкл. |
| pad_image_color | COMBO | white | Padding color for the image (pad). --- Цвет полей изображения (pad). |
| pad_mask_color | COMBO | black | Padding color for the mask (pad). --- Цвет полей маски (pad). |
| invert_mask | BOOLEAN | false | Invert the mask before processing. --- Инвертировать маску перед обработкой. |
| flip_mode | COMBO | none | Mirror AFTER resize: none / horizontal / vertical. --- Отражение ПОСЛЕ ресайза: none / horizontal / vertical. |
| angle_degrees | INT | 0-360–360 | Rotation angle (counter-clockwise), applied BEFORE resize. --- Угол поворота (против часовой), до ресайза. |
| rotation_preset | COMBO | none | Quick angle; overrides angle_degrees. --- Быстрый угол; переопределяет angle_degrees. |
| divisible_by | INT | 00–128 | Round sizes to a multiple (0=off). --- Кратность размеров (0=выкл). |
| device | COMBO | cpu | Compute device: cpu / cuda. --- Устройство: cpu / cuda. |
| input_imageopt | IMAGE | Optional image tensor (priority over the file combo). --- Опциональный тензор изображения (приоритет над файловым комбо). | |
| maskopt | MASK | Optional input mask (priority over the alpha-derived mask). --- Опциональная входная маска (приоритет над альфа-маской). |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| width | INT | — |
| height | INT | — |
| filename | STRING | — |
| filepath | STRING | — |