Skip to main content
Known Participant
October 18, 2011
Question

want to apply layer mask

  • October 18, 2011
  • 1 reply
  • 900 views

Hello all

when i open the image

i want to change background layer and name it source

after i want to apply layermask selection from path

This topic has been closed for replies.

1 reply

c.pfaffenbichler
Community Expert
Community Expert
October 19, 2011

Why not a Vector Mask?

Anyway, this might work – it uses the first path:

// convert background layer and add layer mask from the first path;

// 2011, use it at your own risk;

#target photoshop;

if (app.documents.length > 0 && app.activeDocument.pathItems.length > 0) {

var myDocument = app.activeDocument;

var theLayer = myDocument.layers[myDocument.layers.length - 1];

if (theLayer.isBackgroundLayer == true) {theLayer.isBackgroundLayer = false};

theLayer.name = "source";

var thePath = myDocument.pathItems[myDocument.pathItems.length - 1];

thePath.makeSelection(0, true, SelectionType.REPLACE);

myDocument.activeLayer = theLayer;

// make layer mask;

var idMk = charIDToTypeID( "Mk  " );

var desc168 = new ActionDescriptor();

var idNw = charIDToTypeID( "Nw  " );

var idChnl = charIDToTypeID( "Chnl" );

desc168.putClass( idNw, idChnl );

var idAt = charIDToTypeID( "At  " );

var ref99 = new ActionReference();

var idChnl = charIDToTypeID( "Chnl" );

var idChnl = charIDToTypeID( "Chnl" );

var idMsk = charIDToTypeID( "Msk " );

ref99.putEnumerated( idChnl, idChnl, idMsk );

desc168.putReference( idAt, ref99 );

var idUsng = charIDToTypeID( "Usng" );

var idUsrM = charIDToTypeID( "UsrM" );

var idRvlS = charIDToTypeID( "RvlS" );

desc168.putEnumerated( idUsng, idUsrM, idRvlS );

executeAction( idMk, desc168, DialogModes.ALL );

};

sasientryAuthor
Known Participant
October 19, 2011

how to apply layer mask without selection in soure layer

c.pfaffenbichler
Community Expert
Community Expert
October 19, 2011

Do you mean a Vector Mask?