Skip to main content
Participant
April 23, 2017
Answered

Unpremultiply a layer

  • April 23, 2017
  • 2 replies
  • 1844 views

Hi Guys,

I'm looking for a fast way to unpremultiply a layer with code.

Essentially the function I want is:

1) select layer

2) Layer --> Layer mask --> From Transparency

3) then delete the layer mask

I can't seem to find the calls to activate those functions in JSX.

Any ideas?

This topic has been closed for replies.
Correct answer c.pfaffenbichler
I can't seem to find the calls to activate those functions in JSX.

You might mean you can’t find them in the Document Object Model (DOM), Action Manager (AM) code, such as recorded with ScriptingListener.plugin, should work fine.

2 replies

c.pfaffenbichler
Community Expert
Community Expert
April 23, 2017

Though actually this would nor actually address premultiplication if I understand correctly.

Participant
April 24, 2017

Thanks for clarifying my question. Scriptlistener looks promising but it seems to need the action to be installed on the machine activated making this script unsharable to other users. I tried following that link you sent but it trips on the 'executeAction' once the action is deleted.

Here's my code: Am I missing something?

// =======================================================

function unpremultiply(){

var idPly = charIDToTypeID( "Ply " );

var desc8 = new ActionDescriptor();

var idnull = charIDToTypeID( "null" );

var ref6 = new ActionReference();

var idActn = charIDToTypeID( "Actn" );

ref6.putName( idActn, "unpremultiply" );

var idASet = charIDToTypeID( "ASet" );

ref6.putName( idASet, "Set 1" );

desc8.putReference( idnull, ref6 );

executeAction( idPly, desc8, DialogModes.NO );

}

unpremultiply();

Participant
April 24, 2017

actually don't worry I just ran the wrong code. Human error =P

This worked for me for anyone who wants it in future:

// unpremult layer

function unpremultiply(){

var idMk = charIDToTypeID( "Mk  " );

var desc6 = new ActionDescriptor();

var idNw = charIDToTypeID( "Nw  " );

var idChnl = charIDToTypeID( "Chnl" );

desc6.putClass( idNw, idChnl );

var idAt = charIDToTypeID( "At  " );

var ref4 = new ActionReference();

var idChnl = charIDToTypeID( "Chnl" );

var idChnl = charIDToTypeID( "Chnl" );

var idMsk = charIDToTypeID( "Msk " );

ref4.putEnumerated( idChnl, idChnl, idMsk );

desc6.putReference( idAt, ref4 );

var idUsng = charIDToTypeID( "Usng" );

var idUsrM = charIDToTypeID( "UsrM" );

var idTrns = charIDToTypeID( "Trns" );

desc6.putEnumerated( idUsng, idUsrM, idTrns );

executeAction( idMk, desc6, DialogModes.NO );

}

unpremultiply();

c.pfaffenbichler
Community Expert
c.pfaffenbichlerCommunity ExpertCorrect answer
Community Expert
April 23, 2017
I can't seem to find the calls to activate those functions in JSX.

You might mean you can’t find them in the Document Object Model (DOM), Action Manager (AM) code, such as recorded with ScriptingListener.plugin, should work fine.