Nodes/ComfyUI-JNK-Tiny-Nodes/Load Image if Exist JNK
ComfyUI Node

Load Image if Exist JNK

Load from a path and get a boolean you can branch on

By AljnkΒ·Created about a year agoΒ·Updated 12 months agoΒ· 3
Load Image if Exist JNK
    • image
    • exists
    • index
    β—„image_pathβ–Ί
    β—„show_previewtrueβ–Ί

    Load Image if Exist does exactly what its name promises and then gives you something most image loaders don't: proof of whether it worked. It loads an image from a raw filesystem path and outputs the image plus an exists boolean and an index - so your workflow can branch on whether the file was actually there. That single boolean turns this from a convenience node into a conditional-logic primitive.

    The classic pattern: a workflow that checks whether a previous run's output already exists, and only regenerates if it doesn't. Load the path, inspect exists, and use it with the pack's Switch nodes (or any boolean-aware logic) to skip expensive sampling when the work's already done. Same trick works for checking whether a source asset is present before processing it, so a queue doesn't fail silently on a missing file.

    How it works

    The node checks os.path.exists(image_path). If the file's there, it opens it with PIL, converts to a tensor, and optionally writes a temp preview. If it's not there, you don't get an error - you get a 64Γ—64 black placeholder image, exists = false, and an index of 2. Loaded successfully, exists = true and the index is 1. That placeholder is deliberate: it keeps the graph flowing while making the failure detectable.

    Inputs and outputs

    • image_path - the absolute filesystem path to the image (not a ComfyUI input-folder dropdown).
    • show_preview - whether to render a preview in the UI (default true).

    Outputs:

    • image - the loaded IMAGE, or the 64Γ—64 black placeholder if missing.
    • exists - BOOLEAN: true if the file loaded.
    • index - INT: 1 if loaded, 2 if not.

    Installing it

    Pack install: search JNK in ComfyUI Manager, or

    cd ComfyUI/custom_nodes/
    git clone https://github.com/Aljnk/ComfyUI-JNK-Tiny-Nodes.git
    

    PIL-based, no extra pip packages.

    Where people get burned

    The placeholder is the thing that will get you. Feed that 64Γ—64 black image into a VAE or a sampler without checking exists and you'll get a tiny black result and have no idea why - the node didn't error, so it feels like it "worked." Always branch on exists before using image; that's what it's for. Second, the path is a raw filesystem path - it won't find images in ComfyUI's input folder just by name. And if show_preview is on, each load writes a temp preview file (that's normal, not a leak). Treat it as "load with a status light," and it'll save you a lot of head-scratching.

    CategoryπŸ”§ JNK

    Inputs (2)

    NameTypeDefaultDescription
    image_pathSTRINGβ€”
    show_previewBOOLEANtrueβ€”

    Outputs (3)

    NameTypeDescription
    imageIMAGEβ€”
    existsBOOLEANβ€”
    indexINTβ€”