- Add Group Mask
- "<Image>/Layer/Masks/Add Group Mask (from selection)"
- "<Layers>/Add Group Mask (from selection)"
- PDB Name:
- sg-add-group-mask.scm (after the page appears, click on the "Download" command)
- Create a special layer at the top of a layer group that behaves like a layer mask but for the entire group instead of just a single layer.
The group mask is created by making a selection of the region to be masked (i.e., the unselected regions will be made transparent). Since the fundament of a layer group can not have a mask attached, the group mask is created as the top most layer in the layer group (just below the group's fundament).
Here is the image for which the above layer stack is shown (the XCF can be downloaded from here).
Note that this script is not perfect and is to be considered an interim solution until GIMP obtains group masking capability. In addition to the script producing a layer (instead of a mask), the group mask suffers from "bleeding" whenever the mask is not precisely black and white (due to aliasing or feathering of the mask edges).
Also, while the blend mode of the group mask layer displays as "Normal" in the Layers dialog, it is actually using "Replace" mode which is not available as an option in the user interface. "Replace" mode is an internal mode used by the "Edit->Fade" command and is being abused by this script. If the layer mode of the group mask layer is changed to some other blend mode (e.g., "Soft Light") then the masking will no longer occur and there will be no easy way to change the mode back to "Replace". (One could perform an Alpha To Selection on the group mask layer, delete the layer, and then re-execute the script.)
Finally, it is conceivable that, since the script uses a hidden feature of GIMP layer modes, the GIMP developers might remove this capability in the future (hopefully not before true group masks are implemented).
☡ Given all this, using this script is not particularly recommended and in general artists should plan ahead such that it is not needed; however, in cases where a grouping of layers has already been created and masking is required, this script might prove useful.