Nodes/Load & Resize Image + Filename/Load & Resize Image + Filename
ComfyUI Node

Load & Resize Image + Filename

The Load Image node that also hands you the filename

By Slartibart23·Created 6 months ago·Updated 6 months ago· 0
Load & Resize Image + Filename
    • image
    • mask
    • width
    • height
    • filename
    image
    resizefalse
    width512
    height512
    keep_proportionfalse
    divisible_by2
    upscale_methodlanczos

    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 input directory show up.
    • resize - the master switch. Until this is True, width, height, keep_proportion, divisible_by, and upscale_method do nothing.
    • width / height (default 512) - target dimensions, only used when resize is on. Set keep_proportion to scale uniformly to fit inside them, and divisible_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.

    CategoryKJNodes/image

    Inputs (7)

    NameTypeDefaultDescription
    imageCOMBO1 options: example.png
    resizeBOOLEANfalse
    widthINT5121–16384Target width (only used when resize is enabled)
    heightINT5121–16384Target height (only used when resize is enabled)
    keep_proportionBOOLEANfalse
    divisible_byINT21–256Round output dimensions to be divisible by this value
    upscale_methodCOMBOlanczos5 options: nearest-exact, bilinear, area, bicubic, lanczos

    Outputs (5)

    NameTypeDescription
    imageIMAGE
    maskMASK
    widthINT
    heightINT
    filenameSTRING