#!/usr/bin/env python # Install it in your ~/.gimp/plug-ins/ directory (Could be something like ~/.gimp-2.6/plug-ins). from gimpfu import * def composite(image, tdrawable, background, scale, normalize): pdb.gimp_image_undo_group_start(image) # Will make all layers transparent. So the totall is 100% for i in image.layers: x = 100.0 / len(image.layers) if scale is True: pdb.gimp_layer_scale(i,image.width,image.height,TRUE) pdb.gimp_layer_set_opacity(i,x) if normalize is True: # Add a new layer newlayer = pdb.gimp_layer_new(image, image.width, image.height, 0, 'newlayer', 100, 0) pdb.gimp_image_add_layer(image, newlayer, 1) # colourise layer pdb.gimp_context_set_background(background) pdb.gimp_drawable_fill(newlayer, 1) # Send layer to bottom pdb.gimp_image_lower_layer_to_bottom(image, newlayer) # Merge visible layers image.merge_visible_layers(0) # Normalise colours pdb.plug_in_normalize(image,image.layers[0]) pdb.gimp_image_undo_group_end(image) register( "composite", "Combine (two or more layers) to make a single picture", "Combine (two or more layers) to make a single picture", "Mostafa Hussein", "Mostafa Hussein", "Aug 2011", "/MyScripts/Composite", "*", [ (PF_COLOR, "background", "Background", (255, 255, 255)), (PF_TOGGLE, "scale", "Scale", True), (PF_TOGGLE, "normalize", "Merge and Normalize", True) ], [], composite, ) main()