ComfyUI Node

Image Batch to GIF

Turn a frame batch into an animated GIF (base64 and all)

By turnbros·Created 11 months ago·Updated 10 months ago· 0
Image Batch to GIF
  • images
  • gif_data
frame_duration100
filenameanimation
looptrue
add_frame_numbersfalse
optimizetrue

Image Batch to GIF takes the frames in an image batch and stitches them into an animated GIF. It's the endpoint for "I generated a sequence of frames and I want to see it move" - feed it the IMAGE batch coming out of a video sampler or a batch of animation frames, pick a frame rate, and it hands back the GIF.

The one thing to know up front, because it will trip you up the first time: the gif_data output is not a file path. It's a JSON string with the base64-encoded GIF buried inside a data field, alongside metadata (filename, frame count, duration, dimensions). There's no "Save" button and nothing gets written to disk. To actually get a .gif file you either decode that base64 yourself or plug the output into another pack that knows how to turn it into a file. It's an unusual design - the node is built for workflows where the GIF is destined for something programmatic, like an upload - and it's the first thing a beginner will hit.

Inputs that matter

  • images (required) - the frame batch. A 4D tensor, [batch, height, width, channels], so a normal IMAGE output works.
  • frame_duration (required) - milliseconds per frame, 10–5000, default 100. That's 10 fps at the default; raise it to 200 for a slower 5 fps feel.
  • filename (required) - the base name for the GIF, no extension. Default "animation".
  • loop - whether it loops, default true.
  • add_frame_numbers - stamps "Frame N" in the corner of each frame. Handy for reviewing generated sequences, annoying for the final product.
  • optimize - PIL's GIF optimizer, default true. Worth leaving on; animated GIFs bloat fast.

Outputs

One output, gif_data - a STRING. It's JSON with the base64 GIF in data plus metadata fields. If you're feeding it into the pack's own Media Upload or another tool that expects base64, great; if you want a file, decode it:

python -c "import json,base64,sys; d=json.load(sys.stdin); open(d['filename'],'wb').write(base64.b64decode(d['data']))"

Installing it

ComfyBros installs like any custom node pack. ComfyUI Manager - search "ComfyBros" - or:

cd ComfyUI/custom_nodes
git clone https://github.com/turnbros/ComfyBros

Then restart ComfyUI. The README references a requirements.txt that doesn't exist; the deps are in pyproject.toml (and this node uses PIL, which is included). The node lives under ComfyBros/Image Utils.

Gotchas

The base64-in-JSON output is the big one - don't go hunting for a file on disk. Also note that the default 100 ms/frame is snappy; for an actual "animation" vibe you'll usually want longer durations. And if you feed it a single image rather than a batch, you'll get a one-frame GIF, which is technically valid and entirely pointless - give it multiple frames.

CategoryComfyBros/Image Utils

Inputs (6)

NameTypeDefaultDescription
imagesIMAGE
frame_durationINT10010–5000Duration of each frame in milliseconds
filenameSTRINGanimationFilename for the GIF (without extension)
loopoptBOOLEANtrueWhether the GIF should loop
add_frame_numbersoptBOOLEANfalseAdd frame numbers to each frame
optimizeoptBOOLEANtrueOptimize GIF file size

Outputs (1)

NameTypeDescription
gif_dataSTRING