Python script to save compositing reult? [Pic attached]

Hi guys,

How do I save a composited image using python?


I have set up a group of nodes to add a logo to a bunch of images. However, if I use a “for loop” to save the images with below code, the viewer node will not update in time and it saves tons of images with the same outlook.

        bpy.context.scene.node_tree.nodes['Image'].image = bImg
        bpy.context.scene.update()
        bpy.context.scene.node_tree.nodes['Viewer'].update()
        bpy.data.images['Viewer Node'].save_render("C:/Users/user/Desktop/"+filename.split(".png")[0]+filename+"(with logo).png")

I am not sure how the compositing works. Does it require a trigger to re-render the image after changing the input image?

I know the code to “render” (trigger) and “save the render” (save) will be somewhat like this:

bpy.data.scenes['Scene'].render.filepath="C:/Users/user/Desktop/123.png"

How do I achieve something similar with compositing?

I have found the solution!

The key is to add a “Composite” node to you final output. By hitting F12, this will be the image of the output. Simply put, the code to save the render output will now be the same code to save the composite output.

Thank you.