I do not want my alpha premultiplied when saving images. In blender you can use the compositor Alpha Convert Node to convert from Premultiplied to Straight. I can't seem to find this node in the Python API.


1 Answer 1



You can find a complete list of available compositor node types here: https://docs.blender.org/api/current/bpy.types.CompositorNode.html.

alpha_convert = tree.nodes.new(type='CompositorNodePremulKey')
alpha_convert.mapping = 'PREMUL_TO_STRAIGHT'

However, sometimes it's pretty hard to figure out since the names doesn't really match. I'd suggest create the node in the compositor by hand and print its type to the console to get an idea:

import bpy

class NodeOperator(bpy.types.Operator):
    bl_idname = "node.simple_operator"
    bl_label = "Simple Node Operator"

    def poll(cls, context):
        space = context.space_data
        return space.type == 'NODE_EDITOR'

    def execute(self, context):
        space = context.space_data
        node_tree = space.node_tree
        node_active = context.active_node
        print (node_active.type)
        return {'FINISHED'}

def register():

def unregister():

if __name__ == "__main__":

Or use Node.bl_rna attribute which returns the actual struct (to copy the name from):

>>> node_active.bl_rna
<bpy_struct, Struct("CompositorNodePremulKey")>

Related: Controling compositor by python


You must log in to answer this question.

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