# Can the compositor be used to batch process images?

There are tools to batch process images already of course, (such as ImageMagick), but this isn't as flexible as Blender's compositor since they typically perform linear operations and don't have the control you get with a node-tree.

Is there some way to take point Blender at a directory of images (for example), and batch process them (using an existing compositor setup).

Yes, one not so elegant (no scripting :) but easy way to go about this would be to just use the Movie Clip node and point it to the directory with the images, pass it as input to your node group/compositor setup and render it out as an animation of stills or output each separately using the File Output node.

The only con or drawback to this approach is that the images need to be in a sequence for Blender to iterate through them.. img_001, img_002 ... img_00n or so you can scrub through in the clip editor or timeline but otherwise it should work as desired.

You could setup a blend file with the composite nodes setup as desired, ensuring you start from an image input node and finish with a composite node, then script setting the input and output image names.

import bpy, os

# configure input and oupt dirs
inputDir = '/tmp/input'
outputDir = '/tmp/output'
# ensure this points to the input image node - name can vary
inputNode = bpy.context.scene.node_tree.nodes['Image']

inputImages = os.listdir(inputDir)
bpy.context.scene.render.resolution_percentage = 100

for i in inputImages:
inputNode.image.filepath = os.path.join(inputDir,i)
bpy.context.scene.render.resolution_x = inputNode.image.size[0]
bpy.context.scene.render.resolution_y = inputNode.image.size[1]
bpy.context.scene.render.filepath = os.path.join(outputDir,i)
bpy.ops.render.render(write_still=True)


I have just written a script to batch process images from the compositor.

Example use:

batch_compo.py --blend=compo.blend --input="./img_src/*.png" --output="./img_dst"


Its a single script, but linking to the repository which includes a readme.