🖼️AGSoft Load Image & Mask
One node, image plus mask, zero conversion spaghetti
- image
- mask
- width
- height
- filename
- filepath
The most annoying thing about inpainting in ComfyUI is that your mask doesn't just come along for the ride. The built-in Load Image gives you an image tensor and a filename, and if you want the alpha channel turned into a proper mask you're stringing together conversion nodes before you can even think about a KSampler. AGSoft Load Image & Mask collapses that into one node: load the file, get the image, get the mask (pulled from the alpha channel), and get the dimensions and path to boot. Six outputs, one read.
That single step matters more than it sounds. The usual cutout pipeline - BiRefNet, rembg, or LayerDiffusion - emits transparent PNGs, and the transparent area is exactly the region you want to regenerate or composite into. This node converts that alpha into a ComfyUI MASK (white = affected region, the 1 - alpha convention), so it feeds straight into Set Latent Noise Mask or a KSampler's mask input with nothing in between. If the file has no alpha at all, you get a black mask rather than an error - which is exactly what you want when you only need a placeholder.
How it works
Under the hood it's the standard ComfyUI image loader plus a small trick. It reads the file with PIL, transposes EXIF rotation, walks animated frames (a GIF or animated webp becomes a batched image and a batched mask), and emits the first frame's dimensions. The clever bit is the preview: ComfyUI's built-in image widget can only show files inside your input folder, so when you type an external path into custom_path, the node copies that file into input under an __agsoft_preview__ prefix and points the preview at it. Type a path and the preview updates live; wire the path in from another node and it refreshes after execution. It's a genuinely nice touch for someone who keeps source files outside the ComfyUI tree.
The inputs that matter
There are only two, which is the appeal:
image- the combo box listing yourinputfolder, with an upload button. Used whencustom_pathis empty.custom_path- an absolute path (or a linked string) that overrides the combo. This is the input worth knowing about: the node validates it at connect time, so a typo gets you a clear "Custom path does not exist" instead of a crash mid-run.
Installing it
This ships inside the comfyui-AGSoft pack, a big grab-bag of image, video, audio, text and sampler utilities by a single author. Either route gets it:
# ComfyUI Manager: search "comfyui-AGSoft" and install
# or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Art-xmaster/comfyui-AGSoft.git
# restart ComfyUI
The pack pulls in numpy, opencv-python, and translators (the last one for its translate node) - nothing exotic, and no model downloads for this node. You'll find it in the menu under AGSoft/Image.
Common gotchas
- Black mask out of a PNG that should have transparency? Your file really has no alpha. Save it with transparency (e.g. keep
RGBAfrom your remover), then it'll populate. __agsoft_preview__*.pngfiles keep appearing ininput. That's this node's preview mechanism doing its job, and it deletes its own stale copies. Don't panic, and don't add them to a training set.- The README and tooltips are Russian-first. The author documents nodes on a Telegram channel, so keep a translator handy - the tooltips are bilingual, the docs aren't.
For the version that also resizes the pair in sync, that's the companion AGSoft Load Image & Mask Resize in the same pack - worth a look before you wire a separate resize node in.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | COMBO | Выберите / загрузите изображение из папки input. Используется, если не задан custom_path. --- Select / upload an image from the input directory. Used when custom_path is not set. | |
| custom_pathopt | STRING | Опционально: абсолютный путь к изображению (или линк со строкой). Переопределяет комбо. Превью автоматически переключается на этот файл (после выполнения, если путь пришёл линком). --- Optional: absolute path to an image (or a linked string). Overrides the combo. The preview automatically switches to this file (after execution when the path arrives via a link). |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| width | INT | — |
| height | INT | — |
| filename | STRING | — |
| filepath | STRING | — |