Skip to main content
Participant
June 18, 2020
Answered

use script to change a specific filter setting

  • June 18, 2020
  • 2 replies
  • 1459 views

Hi all,

there is a smartlayer with camera raw filter applied on it:

exposure 1.20

contrast: 20

vibrance 50

 

Now, I want to change one specific value only, lets say: change vibrance to 30.

How can I do it with a script, without resetting all other settings/values? just change vibrance to 30 only...

 

Thank you

This topic has been closed for replies.
Correct answer r-bin
function vibranceCRF(vibValue) 
    {
    var r = new ActionReference();
    r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("smartObject"));
    r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
    var acr = executeActionGet(r).getObjectValue(stringIDToTypeID("smartObject")).getList(stringIDToTypeID("filterFX")).getObjectValue(0).getObjectValue(stringIDToTypeID("filter"));

    var d = new ActionDescriptor();
    var r = new ActionReference();
    r.putIndex(stringIDToTypeID("filterFX"), 1);
    r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
    d.putReference(stringIDToTypeID("null"), r);

    acr.putInteger(charIDToTypeID("Vibr"), vibValue);
    //acr.put ... others

    var d1 = new ActionDescriptor();
    d1.putObject(stringIDToTypeID("filter"), stringIDToTypeID("Adobe Camera Raw Filter"), acr);
    d.putObject(stringIDToTypeID("filterFX"), stringIDToTypeID("filterFX"), d1);

    executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
    }

2 replies

Stephen Marsh
Community Expert
Community Expert
June 19, 2020

EDIT: This may not work as intended...

 

 

vibranceCRF(vibValue = 30); // +30 vibrance

function vibranceCRF() {
    var actDesc = new ActionDescriptor();
    var vibrance = charIDToTypeID("Vibr");
    actDesc.putInteger(vibrance, vibValue);
    executeAction(stringIDToTypeID("Adobe Camera Raw Filter"), actDesc, DialogModes.NO);
}

 

 

 

This would add a new filter to the smart filter stack...

 

There would be the existing value of vibrance = 50

Then there would be a new, second smart filter value added = 30

 

This is not the same thing as changing 50 to 30.

 

Does anybody else have any ideas?

 

aevaxnAuthor
Participant
June 19, 2020

thank you for your answer.

I already manage to make a script, that changes/apply the settings to the current smart filter directly.

The problem is, that it resets all other settings, if there is no entry for it:

 

For example: following script would changes contrast and vibrance, but sets all others to zero....

is there a command to say:

desc762.putInteger( idCronetwo, "KEEP CURRENT VALUE" );

??

 

 

// ##############################################################
var idsetd = charIDToTypeID( "setd" );
var desc760 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref399 = new ActionReference();
var idfilterFX = stringIDToTypeID( "filterFX" );
	ref399.putIndex( idfilterFX, 1 );
	desc760.putReference( idnull, ref399 );

var idfilterFX = stringIDToTypeID( "filterFX" );
var desc761 = new ActionDescriptor();
var idFltr = charIDToTypeID( "Fltr" );
var desc762 = new ActionDescriptor();
var idCMod = charIDToTypeID( "CMod" );
	desc762.putString( idCMod, """Filter""" );


// Change settings
// ##############################################################
var idCronetwo = charIDToTypeID( "Cr12" );
	desc762.putInteger( idCronetwo, 15 );		// CONTRAST

var idVibr = charIDToTypeID( "Vibr" );
	desc762.putInteger( idVibr, 20 );		// VIBRANCE


// ##############################################################
var idAdobeCameraRawFilter = stringIDToTypeID( "Adobe Camera Raw Filter" );
desc761.putObject( idFltr, idAdobeCameraRawFilter, desc762 );
var idfilterFX = stringIDToTypeID( "filterFX" );
desc760.putObject( idfilterFX, idfilterFX, desc761 );
executeAction( idsetd, desc760, DialogModes.NO );

 

 

r-binCorrect answer
Legend
June 19, 2020
function vibranceCRF(vibValue) 
    {
    var r = new ActionReference();
    r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("smartObject"));
    r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
    var acr = executeActionGet(r).getObjectValue(stringIDToTypeID("smartObject")).getList(stringIDToTypeID("filterFX")).getObjectValue(0).getObjectValue(stringIDToTypeID("filter"));

    var d = new ActionDescriptor();
    var r = new ActionReference();
    r.putIndex(stringIDToTypeID("filterFX"), 1);
    r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
    d.putReference(stringIDToTypeID("null"), r);

    acr.putInteger(charIDToTypeID("Vibr"), vibValue);
    //acr.put ... others

    var d1 = new ActionDescriptor();
    d1.putObject(stringIDToTypeID("filter"), stringIDToTypeID("Adobe Camera Raw Filter"), acr);
    d.putObject(stringIDToTypeID("filterFX"), stringIDToTypeID("filterFX"), d1);

    executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
    }
Stephen Marsh
Community Expert
Community Expert
June 19, 2020