Nodes/ComfyUI-Stacker/StackPushImage
ComfyUI Node

StackPushImage

Save images to a stack between workflows, so you only load one big model at a time

By concarne000·Created about a year ago·Updated about a year ago· 10
StackPushImage
  • input_image
  • input_image
    keydefault
    stackpath./ComfyUI/Stack/

    This is the node the whole pack exists for. StackPushImage takes whatever images you feed it and writes them to disk as PNGs inside a stack folder, so a different workflow - or the same one, run later - can pull them back out with StackPopImage. It sounds boring. It solves a genuinely annoying problem.

    Here's the scenario the author built it for: you generate an image with an SDXL checkpoint and ControlNet, then want to feed that image into an image-to-video model. If you wire both into one workflow, ComfyUI has to keep both heavy models around, and you get the reload dance - models swapping in and out of VRAM, queue stalls, OOMs on smaller cards. With the Stacker pack you split it into two workflows: workflow A renders and pushes images, workflow B pops them and runs video. Only one model is resident at a time, and you can run B as many times as you want without ever re-running A.

    How it works

    Mechanically, a "stack" is just a folder on disk. Push nodes write files into ComfyUI/Stack/<key>/, and each file gets a name built from the timestamp plus the batch index. Because those names sort chronologically, "the last file" is the newest - that's what makes a proper last-in-first-out stack possible on the other end.

    The two inputs that matter:

    • input_image - the images to save. A single image, or a batch; each frame in a batch gets its own PNG file.
    • key - the variable name of the stack, default "default". Use "out" here and you'll need a StackPopImage with key = "out" to read it back. Two pushes with different keys create two independent stacks.

    You usually leave stackpath alone - ./ComfyUI/Stack/ relative to your ComfyUI install is a fine home for these. One nice touch: the saved PNGs carry the same embedded workflow/prompt metadata a Save Image node writes, so you can drag them back into ComfyUI later and reconstruct what made them. The node also marks itself as changed on every run (IS_CHANGED returns NaN), which just means it always fires when the queue reaches it - that's deliberate, since a stale stack would otherwise silently replay old data.

    Install

    It's the same for every node in this pack, and it's painless:

    cd ComfyUI/custom_nodes
    git clone https://github.com/concarne000/ComfyUI-Stacker
    

    then restart ComfyUI. Or skip the terminal entirely and search "ComfyUI-Stacker" in ComfyUI Manager. There are no model downloads and no real dependencies - the only thing the pack lists is pickle, which is Python's standard library, so there's nothing to fight over. License is CC0, so no strings attached.

    Gotchas

    • The path is relative to wherever you launch ComfyUI from, not the folder the node code lives in. Launch from somewhere odd and your stacks land somewhere odd.
    • The stack is just files. If you delete the Stack folder, your pushed images are gone with it.
    • Pushing is one-way here. You pull them out with StackPopImage, which by default deletes the file after reading it - that behavior belongs to the pop side, but it's worth knowing the stack is consumable, not archival. Use it for passing data between runs, not long-term storage.
    CategoryConCarne

    Inputs (4)

    NameTypeDefaultDescription
    keySTRINGdefault
    input_imageIMAGE
    stackpathoptSTRING./ComfyUI/Stack/
    input_imageoptIMAGE

    Outputs (0)

    No outputs