Script to pick closest Pantone from CMYK reference in Photoshop

I’m trying to script the process of selecting the closest Pantone+ Solid Coated colour from a CMYK reference in Photoshop.
Manually the process is:

  1. Click on the Foreground Color picker.
  2. Enter a CMYK breakdown.
  3. Click on the Color Libraries button which gives me the closest Pantone colour.

I’m working in the ExtendScript Toolkit and can use the code below to set a new foreground colour. I’m using the ScriptingListener plugin and the code has come from that hence it’s length.

var idsetd = charIDToTypeID( "setd" );
var desc5 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
    var ref2 = new ActionReference();
    var idClr = charIDToTypeID( "Clr " );
    var idFrgC = charIDToTypeID( "FrgC" );
    ref2.putProperty( idClr, idFrgC );
desc5.putReference( idnull, ref2 );
var idT = charIDToTypeID( "T   " );
    var desc6 = new ActionDescriptor();
    var idCyn = charIDToTypeID( "Cyn " );
    desc6.putDouble( idCyn, 97.000000 );
    var idMgnt = charIDToTypeID( "Mgnt" );
    desc6.putDouble( idMgnt, 77.000000 );
    var idYlw = charIDToTypeID( "Ylw " );
    desc6.putDouble( idYlw, 33.000000 );
    var idBlck = charIDToTypeID( "Blck" );
    desc6.putDouble( idBlck, 17.000000 );
var idCMYC = charIDToTypeID( "CMYC" );
desc5.putObject( idT, idCMYC, desc6 );
var idSrce = charIDToTypeID( "Srce" );
desc5.putString( idSrce, """photoshopPicker""" );
executeAction( idsetd, desc5, DialogModes.NO );

What I’m trying to do is get the closest Pantone+ Solid Coated match from the Colour Libraries Picker.

I can see the Pantone reference, in the code that’s being generated by the ScriptingListener plugin, it’s getting that into a variable I’m stuck on.
Please can someone point me in the right direction.

Thanks.

Answer

Attribution
Source : Link , Question Author : TecNik , Answer Author : Community

Leave a Comment