GIMP Script-fu

Artifact [b04ea34320]
Login

Artifact b04ea34320d96fe87d39a672bbc40fe8caa58b41:

Wiki page [sg-add-group-mask] by saulgoode 2015-02-04 20:17:12.
D 2015-02-04T20:17:12.642
L sg-add-group-mask
P 6df40eee4586ee24810d98445926cb57b7c61724
U saulgoode
W 2843
<dl>
<dt><b>Command:</b> <dd>Add Group Mask</dd></dt>
<dt><b>Menu:</b> <dd>"<Image>/Layer/Masks/Add Group Mask (from selection)"</dd>
<dd>"<Layers>/Add Group Mask (from selection)"</dd></dt>
<dt><b>PDB Name:</b> <dd>script-fu-sg-add-group-mask</dd></dt>
<dt><b>Download:</b> <dd>[http://chiselapp.com/user/saulgoode/repository/script-fu/artifact/19b3fd45478ea623|sg-add-group-mask.scm] (after the page appears, click on the "Download" command)</dd></dt>
<dt><b>License:</b> <dd>[copyright|GPLv2+]</dd></dt>

<dt><b>Description:</b> <dd>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).

<center><img src="http://barn.kerosenecow.net/mgoblin_media/media_entries/666/SSgroup-mask.png" /></center>

Here is the image for which the above layer stack is shown (the XCF can be downloaded from [http://barn.kerosenecow.net/u/saul/m/gimp-group-masking/|here]).

<center><img src="http://barn.kerosenecow.net/mgoblin_media/media_entries/665/group-masking.xcf.medium.jpg" />
</center>

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.</dd></dt>
</dl>

Z 5eeb47493a69ced6f10939b153352cd9