adding curves adjustment layer with .acv preset

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

andrew_22

adding curves adjustment layer with .acv preset

Post by andrew_22 »

Hi everyone
I've been searching for such script for several hours and found nothing.
here is ScriptingListener output for such task (i have added curves adj layer, clicked "load curves preset" and then opened the .acv file):
Code: Select allvar idMk = charIDToTypeID( "Mk  " );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref2.putClass( idAdjL );
    desc8.putReference( idnull, ref2 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc9 = new ActionDescriptor();
        var idType = charIDToTypeID( "Type" );
            var desc10 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc10.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
        var idCrvs = charIDToTypeID( "Crvs" );
        desc9.putObject( idType, idCrvs, desc10 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc8.putObject( idUsng, idAdjL, desc9 );
executeAction( idMk, desc8, DialogModes.NO );
but running such script only adds curves adjustment layer with no preset

So does anybody know how to load an .acv preset?

Any help would be greatly appreciated.

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mikaeru

adding curves adjustment layer with .acv preset

Post by Mikaeru »

andrew_22 wrote:So does anybody know how to load an .acv preset?
Any help would be greatly appreciated.
Please try this (it assumes that a valid curves preset file named test.acv is located on your desktop):
Code: Select allfunction makeCurvesAdjustmentLayerFromAcvFile (acvFilePath)
{
   var desc8 = new ActionDescriptor ();
   var ref2 = new ActionReference ();
   ref2.putClass (stringIDToTypeID ("adjustmentLayer"));
   desc8.putReference (stringIDToTypeID ("target"), ref2);
   var desc9 = new ActionDescriptor ();
   var desc10 = new ActionDescriptor ();
   desc10.putEnumerated (stringIDToTypeID ("presetKind"), stringIDToTypeID ("presetKindType"), stringIDToTypeID ("presetKindUserDefined"));
   desc10.putPath (stringIDToTypeID ("using"), new File (acvFilePath));
   desc9.putObject (stringIDToTypeID ("type"), stringIDToTypeID ("curves"), desc10);
   desc8.putObject (stringIDToTypeID ("using"), stringIDToTypeID ("adjustmentLayer"), desc9);
   executeAction (stringIDToTypeID ("make"), desc8, DialogModes.NO);
}
makeCurvesAdjustmentLayerFromAcvFile ("~/Desktop/test.acv");

HTH...
andrew_22

adding curves adjustment layer with .acv preset

Post by andrew_22 »

Mikaeru wrote:HTH...
Thanks man!!! works like a charm
I can now easily load a bunch of saved curves layers to achieve certain looks.

Can you please suggest me some material/resources to check to be better at managing adjustment layers?
Original photoshop-javascript reference is hard to get information from
I was naive to think that changing "curves" to "huesaturation" and ".acv" to ".ahu" in your function would make the same function for hue/saturation, well, it's not)
Mikaeru

adding curves adjustment layer with .acv preset

Post by Mikaeru »

andrew_22 wrote:I was naive to think that changing "curves" to "huesaturation" and ".acv" to ".ahu" in your function would make the same function for hue/saturation, well, it's not)
It does work, actually, except that the relevant StringID is "hueSaturation" (not "huesaturation").

Please try this (again, it assumes that a valid hue/saturation preset file named test.ahu is located on your desktop):
Code: Select allfunction makeHueSaturationAdjustmentLayerFromAhuFile (ahuFilePath)
{
   var desc8 = new ActionDescriptor ();
   var ref2 = new ActionReference ();
   ref2.putClass (stringIDToTypeID ("adjustmentLayer"));
   desc8.putReference (stringIDToTypeID ("target"), ref2);
   var desc9 = new ActionDescriptor ();
   var desc10 = new ActionDescriptor ();
   desc10.putEnumerated (stringIDToTypeID ("presetKind"), stringIDToTypeID ("presetKindType"), stringIDToTypeID ("presetKindUserDefined"));
   desc10.putPath (stringIDToTypeID ("using"), new File (ahuFilePath));
   desc9.putObject (stringIDToTypeID ("type"), stringIDToTypeID ("hueSaturation"), desc10);
   desc8.putObject (stringIDToTypeID ("using"), stringIDToTypeID ("adjustmentLayer"), desc9);
   executeAction (stringIDToTypeID ("make"), desc8, DialogModes.NO);
}
makeHueSaturationAdjustmentLayerFromAhuFile ("~/Desktop/test.ahu");

andrew_22 wrote:Can you please suggest me some material/resources to check to be better at managing adjustment layers?
You may want to have a look at my Layer Object Simplified Format, expressed in JSON syntax.

It is mainly used by my script Adjustment & Fill Gallery, which applies on an existing RGB image an effect made of a stack of adjustment layers and fill layers.

Unfortunately, I do realize now that I haven't documented how to handle preset files, except for the hue/saturation adjustment layer. I'll probably do that soon...

HTH...
andrew_22

adding curves adjustment layer with .acv preset

Post by andrew_22 »

Mikaeru wrote:It does work, actually, except that the relevant StringID is "hueSaturation" (not "huesaturation").
Ha! It works now:)))

Mikaeru wrote:You may want to have a look at my Layer Object Simplified Format, expressed in JSON syntax.

It is mainly used by my script Adjustment & Fill Gallery, which applies on an existing RGB image an effect made of a stack of adjustment layers and fill layers.

Unfortunately, I do realize now that I haven't documented how to handle preset files, except for the hue/saturation adjustment layer. I'll probably do that soon...

HTH...
This is quite interesting stuff!
Thank you for your time and fast reply!