GimpScripts

  1. A function useful to merge layers
  2. Manage a group of layers

A function useful to merge layers

This function can be used in scripts written in the PythonLanguage to merge layers.

   1 def merge(*layers_to_merge):
   2     """ It merges the given layers. """
   3 
   4     if len(layers_to_merge) < 2:
   5         return
   6 
   7     image = layers_to_merge[0].image
   8     for L in layers_to_merge:
   9         if L.image != image:
  10             raise Exception("The given layers doesn't belong to the same image.")
  11 
  12     vis_dict = {}
  13     for L in image.layers:
  14         vis_dict[L.name] = L.visible
  15         if L in layers_to_merge:
  16             L.visible = True
  17         else:
  18             L.visible = False
  19     result = pdb.gimp_image_merge_visible_layers(image, 0)
  20     for L in image.layers:
  21         L.visible = vis_dict[L.name]
  22     return result

Manage a group of layers

[WWW] http://www.box.net/public/i680f363dy

The layers of an image can be grouped using a convention in their names. The groups with the same prefix belong to the same group. The prefix is the part of the name before the character '-' (by default).

To use another delimiter character, change the variable 'delimiter'.

The layers with a name starting with a '#' are not considered.

For example, you can have a stack of layers that looks like:

The groups here are:

last edited 2006-08-19 18:46:38 by ManuelQ