Skip to main content
Participant
June 8, 2009
Question

Loading a layer mask as Selection in Script

  • June 8, 2009
  • 1 reply
  • 2609 views

If you have a layer (Layer 1), that has a mask on it, if you look at the Channel list in Photoshop, you will see a channel named "Layer 1 Mask" of which you can load the selection using the "Load Selection..." dialog.

If a layer has a mask, even if the layer is the active layer, the mask is not a channel object in script. At least, it not exposed.

activeDocument.channels.length returns the number of component channels plus any alpha channels. In an RGB image with only the layer mask it returns 3.

activeDocument.channels.getByName("Layer 1 Mask") throws an error.

So I don't see a way to tell if a layer already has a mask or how to load that mask as a selection, apply or discrad the mask, or turn the mask off without using scriptlistner.

I personally am using C#, and I tried the following which worked:

curDoc.Selection.Load(curDoc.Channels["Blue] ,null, null);

But this doesn't:

curDoc.Selection.Load(curDoc.Channels["Layer 1 Mask"] ,null, null);

Any help would be appreciated

Carl

This topic has been closed for replies.

1 reply

Inspiring
June 8, 2009

As far as I know scriptlistner is the only way to deal with a layer's channel masks. A vector mask is part of the pathItems collection when the layer is active.