Make intermediate render results available in python
Sometimes it is useful to do some post-processing with the render results in a script. This is especially true, if you have multiple view_layers with separate outputs, but only the
Composite
node output is available in
bpy.data.images['Render Result']
.
At the moment one has to use a
File Output
node, write to and reload from disk and handle the temporary files or use a
TempDirectory
like this:
with tempfile.TemporaryDirectory() as temp_dir:
bpy.context.scene.node_tree.nodes["FileOutput"].base_path = temp_dir
bpy.ops.render.render(write_still=False)
# load temp files and do stuff here
This approach is inefficient, unintuitive and error-prone (e.g. file names due to wrong frame, etc.)
A way to access these images in code would really be helpful. There is an options in the UI using ViewNode->Rightside Toolbar->"Save this Image", but testing for an extensive period of time I was not able to access this functionality in code (using blender as python module).
1 Comment
Additional Note: during my search for this functionality I have found multiple stackoverflow, reddit and blender.stackexchange posts spanning over years requesting and looking for the same functionality. Didn't see a similar request posted here, so I thought to post it.