My active image in image editor is Render Result image.
How do I access the layer via Python (I need it to be set to Composite using script)

bpy.data.images["Render Result"].???

enter image description here


2 Answers 2


I need to make sure the layer was 'Composite' because I will need to save the rendered image to the disk using a script. If a user previously set the layer to 'ViewLayer', I will have unwanted results.

Solution I came up with:

  • create a new slot for Render Result image using new_slot = image.render_slots.new()
  • set newly created slot to be active by image.render_slots.active = new_slot
  • then context.view_layer.use = False which will disable layers rendering
  • in Compositing workspace I plugged Image node output into Composite node input using context.scene.node_tree.links.new(...)
  • lastly, I run render bpy.ops.render.render(animation=False, write_still=True, use_viewport=False).

By the end of all this, my new_slot won't have any Layer choose option (because it won't render image from scene cameras), so I can confidently save the rendered image.


bpy.context.scene.render.image_settings.layer = Composite

that may do the trick, haven't tested though

  • 1
    $\begingroup$ image_settings is read only. If this does work it may have unpredictable side effects resulting in crashes. $\endgroup$ Commented Jul 16, 2022 at 20:16
  • $\begingroup$ Thanks, @Aidan, it didn't work, but you gave me the right direction. $\endgroup$
    – kemplerart
    Commented Jul 17, 2022 at 5:31
  • 1
    $\begingroup$ It's read only? I was able to change the render format and file paths via python without error. $\endgroup$
    – Aidan
    Commented Jul 17, 2022 at 7:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .