Batch Processing
Any graph you build for one image can process a whole folder. Swap its first node for Image Folder and its export for Export Batch, and every image in the folder goes through the same steps. Here is the graph from Your First Graph, set up that way:
Every node works on batches as it is. When a batch reaches a node that takes one image, the node runs once per frame and the results are bundled back into a batch, so Levels treats 47 photos exactly as it treats one. A setting you change applies to every frame.
Where a batch comes from
Section titled “Where a batch comes from”A folder on disk. Image Folder reads every matching file in a folder, in the order you choose:
D:/Photos/beach *.jpg;*.png Natural Name sorts shot_2 before shot_10, the way people count. Limit reads only the first few files: set it to 5 while you build the graph, then back to 0 (no limit) to run the whole folder. You can also drop a folder straight onto the canvas.
Images you pick by hand. Collect bundles any images from around the graph into one batch, one input per frame. Drag its rows to reorder the frames, and name and color-code them.
Variants of one image. Palette Remap makes one recolored frame per palette slot; see Palette Variants.
Pieces of one image. Separate cuts a sprite sheet or a scan into one frame per object it finds, or per grid cell.
Multiplying a batch
Section titled “Multiplying a batch”Palette Remap and Separate also accept a batch. Each incoming frame is paired with every palette slot, or every piece, so three characters and a four-color palette give twelve frames on one wire:
{name} Each frame’s name joins the character’s name and the slot’s, so {name} alone gives every pair its own file. A fan-out can grow fast, so Max Fan-Out Output Frames in Settings > Performance caps it: a run that would go past the cap stops with a message instead of filling your memory.
Sending some frames another way
Section titled “Sending some frames another way”Split breaks a batch apart again. In Filter mode it sorts frames by name. Here the hero portraits in a folder of game art get a larger size than everything else:
With the Pattern hero_*, the six files whose names start with hero_ leave on Match and the other 24 on Reject. Split’s other modes cut a batch differently:
- Individual: one output per frame, to wire each into its own place.
- Chunks: a number of equal parts.
- Slice: a run of frames from a start position.
To bring branches back together, wire them into a Collect.
Writing the frames
Section titled “Writing the frames”Export Batch writes one file per frame, named by its File Name. For the photo graph at the top of this page:
export/web {name}_web The Format adds the extension, so the template has none. Naming with Tokens shows how to build names from the frame, its source file, or its number. Turn on Generate Sprite Sheet to pack every frame into one sheet with a JSON file instead. To also write a CSV or JSON list of the frames, add Export Data.
Checking a batch
Section titled “Checking a batch”Select any node carrying a batch and the Preview shows its frames: All lays them out in a grid, and each frame has a tab of its own. For an animation, such as a walk cycle cut from a sheet by Separate, turn on the Playback Bar and play the frames in order, at 1 to 120 frames per second. See Batches and Variants.
A Tag node renames frames and attaches your own labels to them, which the Preview, Export Batch, and Text all read.
Big batches
Section titled “Big batches”- Test small first. Set Image Folder’s Limit to a handful of files until the graph is right.
- Watch it run. Every node in the chain shows a progress bar while a batch runs.
- Tune the machine. Settings > Performance has Batch Concurrency Cap (how many frames run at once) and Batch Memory Ceiling (how much memory frames in progress may use before they go to disk). Both start at an automatic value sized to your computer.
A batch whose frames are whole texture sets is a library, and it flows through the same way; see Texture Sets.