Load & Resize Image + Filename
The Load Image node that also hands you the filename
- image
- mask
- width
- height
- filename
ComfyUI's stock Load Image is weirdly stingy with information. It gives you the pixels and nothing else - no path, no name, nothing you can wire anywhere. If you're processing a folder of inputs and want the output saved as portrait_001.png because the input was portrait_001.png, you end up hardcoding a filename_prefix or bolting on another node just to recover a string. This node is the fix for that: it's a clone of kijai's LoadAndResizeImage from KJNodes with one extra output - a filename STRING you can feed straight into save nodes, text nodes, or prompt builders.
What it is
A single-node pack that does load + alpha-mask extraction + optional resize, then throws in the file's name as a bonus output. It's a thin, honest utility: no model downloads, no API, no heavy dependencies - just torch, Pillow, and numpy, all of which ComfyUI already ships. The whole repo is one commit and one class. It also stands alone: you don't need KJNodes installed to use it, because it reimplements the load logic itself instead of importing it. If the only reason you were eyeing KJNodes was LoadAndResizeImage, this saves you pulling in that entire pack.
How it works
Under the hood it reads from ComfyUI's input folder with a standard file picker, converts the image to a float32 tensor of shape (B, H, W, 3), and extracts the alpha channel into a MASK output. Two details worth knowing: the mask is inverted (transparent pixels become mask=1, which is ComfyUI's "selected/masked" convention), and it handles multi-frame GIF/APNG by stacking every frame into a batch tensor. If resize is on, it runs ComfyUI's built-in common_upscale on both image and mask together so they stay aligned.
The inputs that matter
Most of these you can leave alone. The ones you'll actually touch:
- image - the file picker, same as Load Image. Only files in ComfyUI's
inputdirectory show up. - resize - the master switch. Until this is
True,width,height,keep_proportion,divisible_by, andupscale_methoddo nothing. - width / height (default 512) - target dimensions, only used when resize is on. Set
keep_proportionto scale uniformly to fit inside them, anddivisible_by(default 2) to round the result so the latent model doesn't complain about odd sizes.
upscale_method defaults to lanczos, which is the right call for downscaling to model resolution; leave it.
The output that's the whole point
Five outputs: image, mask, width, height, and the newcomer filename. That last one is the file's stem only - no path, no extension. portrait_001.png comes out as portrait_001. Wire it into a save node's filename_prefix and your outputs finally carry the source name through the whole pipeline. If you need the extension back, add it yourself in a text node.
Installing it
ComfyUI Manager is the easy path: search for "Load & Resize Image + Filename" and install. Manually, the real repo is the V02 one:
cd ComfyUI/custom_nodes
git clone https://github.com/Slartibart23/ComfyUI-LoadResizeImageWithFilenameV02
Then restart ComfyUI. No pip install step - this is as dependency-free as custom nodes get.
Where people get tripped up
The README's manual clone command still points at the old non-V02 repo name; the V02 URL above is the one that exists, so use it if you're not going through Manager. Remember the resize toggle - easy to flip width to 1024 and wonder why nothing changed. And if you're grabbing the filename output for inpainting, double-check the mask polarity before you trust it, because the inversion surprises people used to the stock Load Image mask.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | COMBO | 1 options: example.png | |
| resize | BOOLEAN | false | — |
| width | INT | 5121–16384 | Target width (only used when resize is enabled) |
| height | INT | 5121–16384 | Target height (only used when resize is enabled) |
| keep_proportion | BOOLEAN | false | — |
| divisible_by | INT | 21–256 | Round output dimensions to be divisible by this value |
| upscale_method | COMBO | lanczos | 5 options: nearest-exact, bilinear, area, bicubic, lanczos |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| width | INT | — |
| height | INT | — |
| filename | STRING | — |