Nodes/comfyui-AGSoft/🖼️AGSoft Load Image & Mask Resize (legacy)
ComfyUI Node

🖼️AGSoft Load Image & Mask Resize (legacy)

The resize node that keeps your mask honest

By Art-xmaster·Created 12 months ago·Updated a day ago· 23
🖼️AGSoft Load Image & Mask Resize (legacy)
  • input_image
  • mask
  • image
  • mask
  • width
  • height
  • filename
  • filepath
custom_path
image
resize_modetarget_percentage
target_percentage100.0
target_megapixels1.0
target_width1024
target_height1024
fit_modecrop
crop_positioncenter
interpolationlanczos
resize_if_largernone
resize_if_smallernone
pad_image_colorwhite
pad_mask_colorblack
invert_maskfalse
flip_modenone
angle_degrees0
rotation_presetnone
divisible_by0
devicecpu

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_width or target_height (the other side is computed to keep proportions), or target_both for 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), or pad (keeps everything, fills the rest with a color). The tooltips spell this out, and crop_position decides 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. area is the one to pick when downscaling; nearest if 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.

CategoryAGSoft/Image

Inputs (22)

NameTypeDefaultDescription
custom_pathSTRINGOptional: 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. Нативное превью следует за ним (живо при вводе, после выполнения — если линком).
imageCOMBOSelect / upload an image from the input directory (used when input_image is not connected). --- Выберите / загрузите изображение из папки input (используется, если не подключён input_image).
resize_modeCOMBOtarget_percentageSize mode: percentage / megapixels / width / height / both / longest / shortest. --- Режим размеров: проценты / мегапиксели / ширина / высота / оба / longest / shortest.
target_percentageFLOAT100.00–1000Target size as % of original (100=same, 50=half, 200=double). --- Целевой размер в % от исходного (100=тот же, 50=половина, 200=двойной).
target_megapixelsFLOAT1.00.1–100Target megapixels (MP). Used in target_megapixels mode. --- Целевые мегапиксели (MP). Используется в режиме target_megapixels.
target_widthINT10241–8192Target width (px). Also = the side for longest/shortest modes. --- Целевая ширина (px). Также = сторона для longest/shortest.
target_heightINT10241–8192Target height (px). --- Целевая высота (px).
fit_modeCOMBOcropScaling 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_positionCOMBOcenterAnchor for crop/pad (9 positions). --- Якорь для crop/pad (9 позиций).
interpolationCOMBOlanczosInterpolation. RGBA auto-uses premultiplied alpha. --- Интерполяция. RGBA автоматически с premultiplied alpha.
resize_if_largerCOMBOnonePure 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_smallerCOMBOnonePure 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_colorCOMBOwhitePadding color for the image (pad). --- Цвет полей изображения (pad).
pad_mask_colorCOMBOblackPadding color for the mask (pad). --- Цвет полей маски (pad).
invert_maskBOOLEANfalseInvert the mask before processing. --- Инвертировать маску перед обработкой.
flip_modeCOMBOnoneMirror AFTER resize: none / horizontal / vertical. --- Отражение ПОСЛЕ ресайза: none / horizontal / vertical.
angle_degreesINT0-360–360Rotation angle (counter-clockwise), applied BEFORE resize. --- Угол поворота (против часовой), до ресайза.
rotation_presetCOMBOnoneQuick angle; overrides angle_degrees. --- Быстрый угол; переопределяет angle_degrees.
divisible_byINT00–128Round sizes to a multiple (0=off). --- Кратность размеров (0=выкл).
deviceCOMBOcpuCompute device: cpu / cuda. --- Устройство: cpu / cuda.
input_imageoptIMAGEOptional image tensor (priority over the file combo). --- Опциональный тензор изображения (приоритет над файловым комбо).
maskoptMASKOptional input mask (priority over the alpha-derived mask). --- Опциональная входная маска (приоритет над альфа-маской).

Outputs (6)

NameTypeDescription
imageIMAGE
maskMASK
widthINT
heightINT
filenameSTRING
filepathSTRING