Nodes/ComfyUI-GeN13/Load Latest Image Private (GeN13)
ComfyUI Node

Load Latest Image Private (GeN13)

The drop-a-file-in-a-folder loader that doesn't grab half a file

By heigen13·Created 24 days ago·Updated 12 days ago· 1
Load Latest Image Private (GeN13)
    • IMAGE
    • MASK
    • width
    • height
    • filename
    • path
    • total
    ◄folder_path/tmp/ComfyUI/output►
    ◄sort_bynewest first►
    ◄index0►
    ◄count1►
    ◄filename_filter*►
    ◄subfoldersfalse►
    ◄extensionspng,jpg,jpeg,webp,bmp,tif,tiff►

    There's a workflow pattern that only makes sense once you've used it: you generate a batch, save it to a folder, then a second graph picks up the newest file and upscales it, or animates it, or crops it. No wires between the two, no re-queuing the whole pipeline - you just run the second graph after the first.

    The classic node for this was comfy-load-last-image's Load Most Recent Image. That repo is gone and unmaintained, which is a familiar story in this ecosystem. Load Latest Image Private (GeN13) is the replacement, with sorting, filters, subfolder search, batching, and the pack's privacy cover on the preview.

    What it does

    You give it a folder, and it hands you an image. Point folder_path at anything - it defaults to ComfyUI/output - and set:

    • sort_by - newest first, oldest first, name A-Z, name Z-A. Names sort naturally, so img2 lands before img10 rather than after it. That sounds like a detail until you're picking frames out of a numbered sequence.
    • index - position in that sorted list; 0 is the first file, 1 the second. This is how you walk backwards through your last few generations.
    • count - load up to 64 images in a row starting at index, as one batch. Different sizes get scaled to the first image's size, so a batch is usable.
    • filename_filter - wildcards, e.g. ComfyUI_* or *_upscale*, with ; between multiple patterns. This is the difference between "the newest image anywhere in output" and "the newest thing my first pass wrote".
    • subfolders - include everything below the folder too.
    • extensions - png,jpg,jpeg,webp,bmp,tif,tiff by default, case-insensitive, so you don't get the Windows bug where *.png and *.PNG both match the same file.

    Seven outputs: IMAGE, MASK, width, height, filename, path, total. The last three are what make it usable in a graph that reasons about its input - total tells you how many files matched, filename/path tell you what you actually got, and you can paint those into a Save prefix or a note.

    The two details that stop it being flaky

    First: files still being written are skipped. The node treats a file modified within the last second as potentially in progress and moves on if reading it fails, so a queue that's still saving PNGs won't hand you a truncated image. This is the single most common failure of every naive "load newest file" node, and getting it right is most of the value here.

    Second: caching is signature-based - IS_CHANGED returns the selected file's path, mtime and size, so a new file in the folder re-runs the node and an unchanged folder keeps the cache. Directory scans are cached on the folder's own mtime too, so pointing this at a folder with thousands of files doesn't mean re-listing them every queue.

    The mask convention is the core one: 1 where transparent, all zeros when there's no alpha. Note that the old comfy-load-last-image returned an all-ones mask in that case, which meant the whole image counted as masked downstream. If you're porting a workflow from that node, expect the fix to change your inpainting behaviour, in a good way.

    The privacy half

    The node preview shows the thumbnail and filename it's going to grab, and it uses the same cover system as the pack's other Private nodes - mosaic, frosted, gradient, palette, solid - with hold-to-reveal. Same caveat as the rest of the family: the cover is drawn on the preview, the file is untouched, and privacy defaults to off.

    Since the preview updates on field changes, after each generation, and on a refresh button, it's a decent way to confirm you're about to load the file you think you are - a real risk when your filter is * and your output folder is chaos.

    Installing

    Manager → search GeN13 → install → restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/heigen13/ComfyUI-GeN13
    pip install -r ComfyUI-GeN13/requirements.txt
    

    Requirements file is one line, nvidia-ml-py, for the pack's monitor. This node is Pillow, numpy and torch. No models.

    Practical notes

    folder_path is a full path, not a name - including on Windows, where you'll want something like D:\ComfyUI\output\renders. Getting that wrong is the usual reason nothing loads, and it fails quietly with an empty/black image rather than a helpful error.

    Pair it with Counter (GeN13) for the walking pattern: Counter's output into index, and each queue grabs the next-newest file. That's how you batch-process a folder of previous renders one at a time without building an actual list node.

    CategoryGeN13/image

    Inputs (7)

    NameTypeDefaultDescription
    folder_pathSTRING/tmp/ComfyUI/outputFolder: full path of the folder to load from.
    sort_byCOMBOnewest firstSort by: newest first puts the most recently saved file first; name sorts file names in natural order.
    indexINT00–99999Index: position in the sort order; 0 is the first image, 1 the second, and so on.
    countINT11–64Count: images loaded in a row from index, as one batch. Different sizes are scaled to the first image.
    filename_filterSTRING*Filename filter: wildcards such as ComfyUI_*; separate multiple patterns with ;.
    subfoldersBOOLEANfalseSubfolders: INCLUDE also searches every subfolder below.
    extensionsSTRINGpng,jpg,jpeg,webp,bmp,tif,tiffExtensions: comma-separated, not case-sensitive.

    Outputs (7)

    NameTypeDescription
    IMAGEIMAGEImage: a single image or a batch.
    MASKMASKMask: 1 in transparent areas; all 0 when the image has no alpha channel.
    widthINTWidth: output image width in px.
    heightINTHeight: output image height in px.
    filenameSTRINGFilename: name of the first image, without path.
    pathSTRINGPath: full path of the first image.
    totalINTTotal: number of matching files.