user3768356
user3768356

Reputation: 107

How can I use Photoshops Match Color function through javascript

I'm wondering if there is syntax to use Match Color, I've looked through the Adobe Photoshop CS3 JavaScript Reference here , and didn't find anything on it.

I'm working on color balancing a lot of imagery, and being able to select a target image through "Match Color" is a great functionality. And being able to use a script would be great.

Upvotes: 1

Views: 285

Answers (1)

ShooTerKo
ShooTerKo

Reputation: 2282

Playing with the ScriptingListener.plugin gives me something like:

// =======================================================
var idmatchColor = stringIDToTypeID( "matchColor" );
    var desc3 = new ActionDescriptor();
    var idLght = charIDToTypeID( "Lght" );
    desc3.putInteger( idLght, 98 );
    var idClrR = charIDToTypeID( "ClrR" );
    desc3.putInteger( idClrR, 98 );
    var idFade = charIDToTypeID( "Fade" );
    desc3.putInteger( idFade, 8 );
    var idneutralizeColor = stringIDToTypeID( "neutralizeColor" );
    desc3.putBoolean( idneutralizeColor, true );
    var idfsel = charIDToTypeID( "fsel" );
    desc3.putBoolean( idfsel, true );
    var idSrce = charIDToTypeID( "Srce" );
        var ref1 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idBckg = charIDToTypeID( "Bckg" );
        ref1.putProperty( idLyr, idBckg );
        var idDcmn = charIDToTypeID( "Dcmn" );
        ref1.putName( idDcmn, "Test_Image.jpg" );
    desc3.putReference( idSrce, ref1 );
executeAction( idmatchColor, desc3, DialogModes.NO );

You can find the settable parameters from UI here translated into Photoshop Javascript, i.e. Fade is set to a value of 8 or the Neutralize checkbox is checked (true).

In the third last line you see the calculation source set to Test_Image.jpg here.

I think this gives you a good starting point to go on. I recommend to replace the values here (98, 98, 8 etc.) with variables and wrap it in a JS function.

Greetings, Michael / Hamburg

Upvotes: 1

Related Questions