Nodes/Ranbooru for ComfyUI/RandomPicturePath
ComfyUI Node

RandomPicturePath

Random image picker that returns a path string, not pixels

By Inzaniak·Created 3 years ago·Updated 3 months ago· 26
RandomPicturePath
    • STRING
    path
    parse_subfoldersTrue
    use_lastfalse

    RandomPicturePath points at a folder and hands back the full path to a random image inside it. That's the whole job - and the key thing to internalize is in the name: it returns a path string, not an image tensor. You still need a loader (LoadImage or similar) downstream to actually turn that path into pixels.

    Where does that earn its keep? Any workflow that wants to vary its reference image without you curating it by hand: random reference batches, random inpaint sources, feeding a queue of images for upscaling or img2img roulette. It's the same "let the machine shuffle" spirit as the rest of this pack, just for files instead of booru tags.

    How it works

    It scans the folder for .png, .jpg, and .jpeg files, picks one with random.choice, and returns the full path as a STRING. Two toggles shape the scan:

    • parse_subfolders - recursive scan. Worth knowing this is an enum of strings ("True" / "False"), not a real boolean - it's a dropdown in the UI, but its type is a string, so don't try to feed it a boolean from another node.
    • use_last - freeze the last picked path instead of re-rolling.

    Because it's one of the pack's always-rerun nodes, it re-picks on every queue run - flip use_last on when you want to keep the current choice while you tweak something else.

    Inputs and outputs

    • path - STRING, the folder to scan.
    • parse_subfolders - enum "True" / "False", default "True".
    • use_last - BOOLEAN, default off.

    Output: STRING, the absolute path to a random image.

    Installing it

    Part of the Ranbooru pack: ComfyUI Manager, search "Ranbooru", or

    cd ComfyUI/custom_nodes
    git clone https://github.com/Inzaniak/comfyui-ranbooru
    

    then restart. No requirements.txt, no model downloads - it imports only os and random.

    Common issues

    The number-one gotcha is wiring the output straight into an IMAGE input and wondering why nothing connects. It's a string path; put a LoadImage after it. Second, an empty or mistyped path just crashes - this node doesn't validate or show a nice picker, it calls the OS directly, so a bad path means an error in the queue log rather than a friendly warning. And because the extension filter is exact, webp and gif files are silently ignored even if they're in the folder; only png/jpg/jpeg count. That's fine for booru-derived datasets, but if your reference folder is full of webps, they'll never get picked.

    CategoryRanbooru Nodes

    Inputs (3)

    NameTypeDefaultDescription
    pathSTRING
    parse_subfoldersCOMBOTrue2 options: True, False
    use_lastBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    STRINGSTRING