Nodes/KJNodes for ComfyUI/Load & Resize Image
ComfyUI Node Runs on cloud

Load & Resize Image

Load, resize, and grab a mask in one node

By kijai·Created 3 years ago·Updated about 12 hours ago· 2,930
Load & Resize Image
    • image
    • mask
    • width
    • height
    • image_path
    image
    resizefalse
    width512
    height512
    repeat1
    keep_proportionfalse
    divisible_by2
    mask_channel
    background_color

    This is the node you use when you're tired of wiring a Load Image into a Resize into a mask extractor every single time. LoadAndResizeImage collapses that whole opening chain into one box. You pick a file, and out the other side comes the image, a mask, the dimensions, and even the file path - already resized to whatever your model needs. It's a small quality-of-life thing, but if you build a lot of img2img or inpainting graphs, it saves you three nodes on every one of them.

    What it actually does

    Core ComfyUI's Load Image gives you an image and a mask and nothing else. This one bolts a resize step and a few extras directly onto the loader, so the picture is the right size before it leaves the node. That matters because you don't have to remember to round dimensions to a model-friendly multiple downstream - the node handles it inline.

    The inputs worth setting

    • image - the file picker, same as the stock loader. It reads from your ComfyUI input folder.
    • resize - the master switch. Off, it behaves like a normal loader. On, width, height, keep_proportion, and divisible_by come into play. divisible_by snaps the final size to a clean multiple (set it to 8 or 64 to keep your model happy); keep_proportion treats width/height as a bounding box instead of stretching.
    • repeat - duplicates the loaded image into a batch of N copies. Genuinely useful for seeding a video workflow or running the same init image through a batch of seeds without a separate repeat node.
    • mask_channel - which channel becomes the MASK output: alpha, red, green, or blue. If your PNG has transparency, leave it on alpha; if you baked a mask into a color channel, point it there.
    • background_color - a string color used to fill transparency when there's an alpha channel. Leave it empty to keep the alpha as a mask; set it to composite the image onto a solid background.

    The outputs are the full set: image, mask, width, height, and image_path as a string. That last one is quietly handy - you can feed the path into a text/log node or use it to name saved outputs after the source file.

    Installing KJNodes

    In ComfyUI Manager, search "KJNodes for ComfyUI" in the Custom Nodes Manager, install, restart. Manual route: cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, then pip install -r ComfyUI-KJNodes/requirements.txt (portable: python_embeded\python.exe -m pip install -r ComfyUI\custom_nodes\ComfyUI-KJNodes\requirements.txt), then restart ComfyUI. The pack keeps dependencies minimal on purpose, so there's nothing heavy to download and no model files for this node - it's all local image handling.

    Common snags

    The mask output confuses people. If you point mask_channel at alpha but your image has no alpha channel, you'll get a blank (all-black or all-white) mask and wonder why your inpaint isn't masking anything. Match the channel to what's actually in the file.

    The repeat field is a trap in the other direction: crank it up carelessly and you've just built a giant batch that eats VRAM and time. It defaults to 1 for a reason.

    And if the node doesn't show after install, it's the usual custom-node checklist - run the requirements install, restart fully, and check ComfyUI Manager for import errors. KJNodes has been kept current through ComfyUI's Nodes 2.0 frontend changes, so you shouldn't hit the compatibility breakage that snagged some older utility packs.

    CategoryKJNodes/image

    Inputs (9)

    NameTypeDefaultDescription
    imageCOMBO1 options: example.png
    resizeBOOLEANfalse
    widthINT5120–16384
    heightINT5120–16384
    repeatINT11–4096
    keep_proportionBOOLEANfalse
    divisible_byINT20–512
    mask_channelCOMBOChannel to use for the mask output
    background_colorSTRINGFills the alpha channel with the specified color.

    Outputs (5)

    NameTypeDescription
    imageIMAGE
    maskMASK
    widthINT
    heightINT
    image_pathSTRING