OpenCV haveImageReader_0
Before you load that file, ask OpenCV if it can read it at all
- bool
haveImageReader_0 checks whether a given filename is something OpenCV can actually decode as an image. One string in, one boolean out. It doesn't load the image - it peeks at it and reports whether a read would succeed. That's the whole job, and it's more useful than it sounds if you've ever loaded a workflow that assumes a file exists.
How it works
Under the hood it's cv2.haveImageReader(filename). OpenCV looks at the file extension, then actually opens the file header to see if a matching image codec can decode it. That second part matters: it's not a pure extension check. A .jpg that's actually a text file will come back False, and a .png that's been truncated will too. It's the closest thing to "will imread succeed" without paying for the read.
The pack wires it as a STRING input and a BOOLEAN output, exactly as generated.
Where you'd use it
This node is really about workflow guards. Pair it with the pack's imread_0 / imdecode_0 nodes: check haveImageReader_0 first, and if it's False, route around the load instead of letting the read blow up mid-graph. You can also use it to probe a directory of files and only process the ones that are genuinely images - a real scenario if you're feeding a batch through a file-watching workflow.
Honest caveat: in pure ComfyUI, most people never touch this because LoadImage handles this internally and fails with a friendly error anyway. The node earns its keep the moment your pipeline takes a filename as data - from a text input, a file-picker, or a path you built with a string node - and you want to fail gracefully instead of crashing.
Input and output
filename(STRING) - a path on disk. Relative paths resolve against ComfyUI's working directory, so an absolute path is safer.bool(BOOLEAN) -Trueif OpenCV can decode the file,Falseif it can't (or the file doesn't exist - that also returnsFalse, no exception).
Install
One of ~635 nodes in the auto-generated opencv-comfyui pack:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
or search "OpenCV" in ComfyUI Manager. Then:
pip install opencv-contrib-python
No model files. The pack's requirements.txt is just OpenCV, numpy, and torch.
Gotchas
Don't confuse this with haveImageWriter_0, which is the same idea for writing and only inspects the extension. And remember the pack speaks NPARRAY, not Comfy IMAGE - this node sidesteps that entirely since it only takes a string, which makes it one of the friendlier nodes in the pack. It's a thin utility, but a truthful one: if it says False, believe it, and save yourself the crash.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| filename | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| bool | BOOLEAN | — |