Nodes/zhangp365/ComfyUI-utils-nodes/Load Image with Switch
ComfyUI Node

Load Image with Switch

An image loader you can disable without disconnecting it

By zhangp365·Created 2 years ago·Updated 5 months ago· 134
Load Image with Switch
    • image
    • mask
    • enabled
    image
    enabledtrue

    Stock LoadImage always loads whatever file is selected. This version adds one field, enabled, and when it's off, the node simply doesn't load the image - per the author's own description of it. That's a small change with a genuinely useful downstream effect: it turns a fixed image source into something you can toggle in and out of a workflow the same way you'd flip off any other step.

    Why an image loader needs an off switch

    The obvious use is a workflow with two possible image sources - a fixed reference image loaded from disk, versus something generated upstream in the same graph - where you want to switch between them without rewiring. Pair this node with something like ImageAutoSelector or one of this pack's *WithSwitch compositors: when enabled is off here, there's nothing for this branch to feed downstream, and the fallback or alternate path takes over instead.

    It's also just convenient for iterating: disable the loader while you're testing a different part of the graph, without losing the file selection or having to physically unplug the node and remember to plug it back in later.

    Inputs and outputs

    • image - the standard ComfyUI file picker, populated from your input folder.
    • enabled (optional, default true) - the addition.

    Three outputs: image (IMAGE), mask (MASK, derived from the source file's alpha channel the same way stock LoadImage does it), and enabled (BOOLEAN) - the toggle state itself, passed straight through as an output.

    That last one is worth calling out specifically: forwarding enabled as its own output means you can wire the same boolean into other switch-aware nodes downstream - say, this pack's ImageCompositeMaskedWithSwitch - so one checkbox drives multiple nodes in sync instead of duplicating the same toggle in three places and keeping them manually consistent.

    Installing it

    ComfyUI Manager: search "ComfyUI-utils-nodes." Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/zhangp365/ComfyUI-utils-nodes
    

    Restart ComfyUI. No extra dependencies - it's a thin wrapper over core LoadImage.

    What to watch for

    When enabled is off, the image output isn't a valid image - treat this node as one link in a chain that has to handle the "nothing loaded" case somewhere downstream, not as something safe to plug straight into a sampler or VAEEncode expecting real pixels every run. If a downstream node errors with something like a missing or None image and you've got this node's enabled toggled off, that's almost certainly the cause - check that switch before assuming the file itself is bad.

    Categoryutils/image

    Inputs (2)

    NameTypeDefaultDescription
    imageCOMBO1 options: example.png
    enabledoptBOOLEANtrue

    Outputs (3)

    NameTypeDescription
    imageIMAGE
    maskMASK
    enabledBOOLEAN