GIMP Script-fu

Artifact [fd68ff9cb2]
Login

Artifact fd68ff9cb22b72e4457ee449c406494be2536e68:

Wiki page [sg-copy-mask-from-above] by saulgoode 2014-12-06 17:57:43.
D 2014-12-06T17:57:43.309
L sg-copy-mask-from-above
P f85c25086d7ae8b92b82fc828574da1598d58c4d
U saulgoode
W 2499
<dl><dt><b>Command:</b> <dd>Copy Mask From Above</dd></dt>
<dt><b>Menu:</b> <dd>"<Image>/Layer/Mask/Copy Mask From Above"</dd>
<dd>"<Layers>/Copy Mask From Above"</dd></dt>
<dt><b>PDB Name:</b> <dd>script-fu-sg-copy-mask-from-above</dd></dt>
<dt><b>Download:</b> <dd>[http://chiselapp.com/user/saulgoode/repository/script-fu/artifact/2200b3f934fa1806ded9cf9b9e3270325be13e3f|sg-copy-mask-from-above.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>This script copies the layermask from the visible layer directly above the active layer in the layer stack. The command is available in both the "Layer->Mask" submenu and in the Layers context menu (that appears when you right-click on a layer).

The result follows the following rules:
<ul><li>If the active layer already has a mask, it will be replaced by the new mask.</li>
<li>If the above layer has a mask, that mask will be added to the active layer.</li>
<li>If the above layer does not have a mask, a grayscale copy of the above layer will be added to the active layer -- unless the above layer is a text layer, in which case the text is used for the mask.</li>
<li>If there is no visible layer above the active layer, a mask will be added and initialized from the selection.</li></ul>

Here are some screenshots of the Layers dialog for a few different scenarios. The dialog on right is the result after running the script.

Layer directly above active layer is visible and has a layermask. That mask is added to the active layer.

<center><img src="http://barn.kerosenecow.net/mgoblin_media/media_entries/27/SScopy-mask0.png" />
</center>

Same as before but here the active layer already has a layermask (this layermask gets replaced by the new one).

<center><img src="http://barn.kerosenecow.net/mgoblin_media/media_entries/28/SScopy-mask0b.png" />
</center>

Layer directly above active layer is visible but does not have a layermask. A grayscale copy of that layer is added to the active layer.

<center><img src="http://barn.kerosenecow.net/mgoblin_media/media_entries/30/SScopy-mask1a.png" />
</center>


The layer directly above the active layer is hidden and therefore ignored. The mask is created based upon the first visible layer above the active layer.

<center><img src="http://barn.kerosenecow.net/mgoblin_media/media_entries/29/SScopy-mask1.png" />
</center>

</dd>
</dt>
</dl>

Z 78437d869090445a3cf2d65aaa89da1e