Nodes/Various ComfyUI Nodes by Type/Image Load RGB If Exists
ComfyUI Node

Image Load RGB If Exists

Load an image, or fall back if it's missing

By jamesWalker55·Created 3 years ago·Updated about a year ago· 215
Image Load RGB If Exists
  • default
  • IMAGE
path./image.png

JWImageLoadRGBIfExists loads an image from a path if the file is there - and if it isn't, it quietly hands back a fallback image you provided instead of crashing the run. It's the "optional input" version of loading by path, and it's a genuinely clever little building block for reusable workflows.

Here's the problem it solves. A normal load-by-path node errors out when the file is missing, which kills the whole graph. But sometimes you want a file to be optional: a template workflow where an extra reference image, a mask, or a previous-frame input might or might not exist. With this node you set a sensible default, point path at the maybe-there file, and the graph runs either way - using the real file when present, the fallback when not. That's the difference between a workflow that breaks on a missing file and one that gracefully degrades. Great for batch jobs, iterative loops (where "the previous frame" doesn't exist on iteration one), and shareable templates.

What it actually does

It checks whether a file exists at path. If yes, it loads it as an RGB IMAGE (same behavior as JWImageLoadRGB - alpha stripped, three channels). If no, it passes through the default image you wired in. Either way you get a valid IMAGE out, so nothing downstream ever sees a hole.

The inputs and outputs that matter

  • default (IMAGE) - the fallback, used when the file isn't found. This is required - you have to give it something to fall back to.
  • path (STRING, default ./image.png) - the file to load if it exists.

Output is a single IMAGE: the loaded file, or the default. Downstream nodes can't tell which they got, which is exactly the point.

How to install it

Pack: jamesWalker55/comfyui-various. ComfyUI Manager - search Various ComfyUI Nodes by Type, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/jamesWalker55/comfyui-various

then restart. No dependencies. It's one of the image-loading utilities in comfyui_image_ops.py, so you can grab that single file if you only want the image nodes.

Common issues & troubleshooting

You must wire a default. The fallback isn't optional - the node needs a real IMAGE to fall back on. If you leave default unconnected, there's nothing for it to return when the file is missing. A blank/solid image (from JWMaskLikeImageSize's cousins or an empty-image node) is a common choice.

Same server-path caveat as JWImageLoadRGB. The existence check runs on the machine hosting ComfyUI, not your local computer. On a cloud or serverless setup like comfy.icu, "does this file exist" is asked of the GPU worker's filesystem - so a path to a file on your laptop will always resolve as missing and you'll silently get the fallback every time. If you're always getting the default when you expected the real image, that mismatch is usually why.

It fails quietly by design. Because a missing file gives you the fallback instead of an error, a typo in the path won't announce itself - you just get the default. If results look wrong, verify the path actually points where you think it does.

CategoryjamesWalker55

Inputs (2)

NameTypeDefaultDescription
defaultIMAGE
pathSTRING./image.png

Outputs (1)

NameTypeDescription
IMAGEIMAGE