Skip to main content
Inspiring
April 5, 2018
Answered

Spot color creation in Photoshop CS6, javascript

  • April 5, 2018
  • 2 replies
  • 1555 views

Hi,

I need to create spot channel value: CMYK: 50:0:0:0, at 50% solidity, named 'hpWhite' in Photoshop CS6, javascript.

How can I do it?

Thank you.

Yulia

This topic has been closed for replies.
Correct answer c.pfaffenbichler

Record the creation with ScriptingListener.plugin and use the resulting code.

If you prefer to use DOM code

#target photoshop

var myDoc = activeDocument;

var theColor = new SolidColor();

theColor.cmyk.cyan = 50;

theColor.cmyk.magenta = 0;

theColor.cmyk.yellow = 0;

theColor.cmyk.black = 0;

var theCh = myDoc.channels.add();

theCh.kind = ChannelType.SPOTCOLOR;

theCh.name = "test";

theCh.opacity = 50;

theCh.color = theColor;

2 replies

Tom Winkelmann
Inspiring
April 5, 2018

And here the AM-Code from ScriptListener...

var idMk = charIDToTypeID( "Mk  " );

    var desc66 = new ActionDescriptor();

    var idNw = charIDToTypeID( "Nw  " );

        var desc67 = new ActionDescriptor();

        var idNm = charIDToTypeID( "Nm  " );

        desc67.putString( idNm, """hpWhite""" );

        var idClr = charIDToTypeID( "Clr " );

            var desc68 = new ActionDescriptor();

            var idCyn = charIDToTypeID( "Cyn " );

            desc68.putDouble( idCyn, 50.000000 );

            var idMgnt = charIDToTypeID( "Mgnt" );

            desc68.putDouble( idMgnt, 0.000000 );

            var idYlw = charIDToTypeID( "Ylw " );

            desc68.putDouble( idYlw, 0.000000 );

            var idBlck = charIDToTypeID( "Blck" );

            desc68.putDouble( idBlck, 0.000000 );

        var idCMYC = charIDToTypeID( "CMYC" );

        desc67.putObject( idClr, idCMYC, desc68 );

        var idOpct = charIDToTypeID( "Opct" );

        desc67.putInteger( idOpct, 50 );

    var idSCch = charIDToTypeID( "SCch" );

    desc66.putObject( idNw, idSCch, desc67 );

executeAction( idMk, desc66, DialogModes.NO );

c.pfaffenbichler
Community Expert
c.pfaffenbichlerCommunity ExpertCorrect answer
Community Expert
April 5, 2018

Record the creation with ScriptingListener.plugin and use the resulting code.

If you prefer to use DOM code

#target photoshop

var myDoc = activeDocument;

var theColor = new SolidColor();

theColor.cmyk.cyan = 50;

theColor.cmyk.magenta = 0;

theColor.cmyk.yellow = 0;

theColor.cmyk.black = 0;

var theCh = myDoc.channels.add();

theCh.kind = ChannelType.SPOTCOLOR;

theCh.name = "test";

theCh.opacity = 50;

theCh.color = theColor;

Inspiring
April 6, 2018

Thank you, the js works, the only thing about it, it fills the surface with the color. Could it not do it. I only need to have spot channel.

Tom Winkelmann
Inspiring
April 6, 2018

Don't know what you expect, but you can invert the channel layer...

DOM-code:

app.activeDocument.activeLayer.invert();

AM-Code:

var idInvr = charIDToTypeID( "Invr" );

executeAction( idInvr, undefined, DialogModes.NO );


Or do you wanna hide it?