Image Hash ๐
A short deterministic hash for cache-key filenames
- images
- hash
Turn an image into a short, stable string. That string is the same every time for the same image and different for a different one, which makes it perfect for one job in particular: building deterministic cache-key filenames. ImageHash is the node you use when you want to name a file after its input so you can check later whether you've already produced it.
Part of ComfyUI-MieNodes (ComfyUI_MieNodes), MieMieeeee's utility pack, in the Common group.
Why you'd use it
The killer use is caching expensive work. Say a heavy node takes an image and spends real time producing something from it. If you hash the input image and use that hash in the output filename, then next run you can ask FileExists whether that exact file is already on disk - and skip the expensive step if it is. The hash is what makes the filename deterministic: same image in, same name out, so the cache actually hits. It's the companion to StringHash, which does the same trick for text inputs (like a prompt word).
There's a second, adjacent use worth knowing. Content hashing is the mechanism behind image deduplication - the pack's DedupImageFiles node removes near-identical images from a folder by comparing hashes within a distance threshold. That matters for LoRA datasets: the KB's LoRA-training doc is emphatic that dataset curation beats every knob, and that a well-curated small set beats a careless large one. Hashing helps you spot and cull the duplicates that quietly poison a training set.
The frame_limit input is the tell that this handles batches and video, not just single images - you can cap how many frames get folded into the hash so you're not hashing every frame of a long clip.
The inputs and outputs that matter
Required:
images(IMAGE) - the image, batch, or video frames to hash.
Optional:
frame_limit(INT, default 0) - a cap on how many frames to include.0is the default; raise it to bound the work when you're hashing a big batch/video.
Output:
hash(STRING) - the short digest. Drop it into a filename (via string concat or a SaveAnythingAsFile name) to build a stable cache key.
Installing it
ComfyUI Manager โ search ComfyUI-MieNodes โ install โ restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/MieMieeeee/ComfyUI-MieNodes
then restart. No model download. Nodes appear under the ๐ MieNodes menu.
Common issues
It's a caching/identity tool, not a similarity score you read. The output is a string meant to be used as a key, not a human-readable "how similar are these" number. If you want to dedup a folder, use DedupImageFiles (which uses hashing internally with a distance threshold); ImageHash is the lower-level primitive.
Tiny changes change the hash. For cache-key purposes that's exactly what you want - a different image should get a different name. But don't expect two visually-almost-identical images to hash the same unless the underlying method is specifically perceptual with tolerance. For "close enough" matching, that's the dedup node's threshold, not this.
Pair it with FileExists to actually cache. On its own the hash does nothing - the skip-if-cached behavior comes from using the hash in a filename and checking it with FileExists. And remember that on serverless/cloud ComfyUI the output folder may be ephemeral, so the cache pattern pays off most on a local install.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | โ | |
| frame_limitopt | INT | 00โ100000 | โ |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| hash | STRING | โ |