Nodes/Bjornulf_custom_nodes/๐ŸŽฒ๐Ÿ–ผ Random Image
ComfyUI Node

๐ŸŽฒ๐Ÿ–ผ Random Image

Pick one image at random from a set of candidates

By justUmenยทCreated 2 years agoยทUpdated about a year agoยท 545
๐ŸŽฒ๐Ÿ–ผ Random Image
    • IMAGE
    โ—„number_of_images2โ–บ

    The image equivalent of picking a random line from a list of text - wire in several images, get one back at random each run. It's a small node, but it's the right tool when you want variety without processing every candidate, which is the key difference from the pack's Loop (Images) node that runs through all of them.

    How it works

    Set number_of_images to how many candidate sockets you want (1 to 10), wire an image into each, and the node returns one of them at random per run. There's no seed control listed on this node, so the randomness ties to ComfyUI's own re-execution behavior rather than a dedicated seed widget - practically, that means you'll want a control_after_generate-style trigger somewhere upstream, or accept that a fully cached, unchanged input set may not reroll on its own between runs.

    The obvious use is injecting variety into a batch - a reference image node in a larger pipeline, a background plate, a style reference - where you want the workflow to grab something different each time without you manually swapping which image is connected. It pairs naturally with the pack's Loop (Images) node: use Random Image when you want one surprise pick per run, use Loop (Images) when you want to methodically process every image in the set.

    The inputs and outputs that matter

    • number_of_images (1โ€“10, default 2) - how many image sockets to show. Wire a different image source into each.
    • Output: IMAGE - whichever one got picked.

    How to install it

    Through ComfyUI Manager: search Bjornulf_custom_nodes, install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/justUmen/Bjornulf_custom_nodes
    

    cd into the folder, pip install -r requirements.txt (a venv is worth the extra minute), restart ComfyUI. This node has no dependency of its own beyond what the shared pack requires to import cleanly.

    Common issues

    Because there's no seed input on this node, the most common point of confusion is expecting a fresh random pick every single queue press and not getting one - if none of this node's own inputs changed and ComfyUI's cache considers it unchanged, it may just return the same cached selection. If you need a guaranteed reroll every run, wire in something upstream that changes each time (a randomized seed value from elsewhere in the pack, for instance) so the node's inputs are never identical twice.

    And as with the rest of this pack, if the node is missing from your search entirely rather than misbehaving, that's usually a dependency import failure somewhere else in the shared requirements.txt, not this node specifically - check the ComfyUI startup console first.

    CategoryBjornulf

    Inputs (1)

    NameTypeDefaultDescription
    number_of_imagesINT21โ€“10โ€”

    Outputs (1)

    NameTypeDescription
    IMAGEIMAGEโ€”