• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Modifying Levels Adjustment Layer?

New Here ,
Oct 10, 2013 Oct 10, 2013

Copy link to clipboard

Copied

I'm using PS CS6 x64 for Win7. I'm trying to figure out how to change the values on a "levels" adjustment layer using javascript. I can't find any info anywhere. Oddly, the scripting listener doesn't seem to pick up modifications to the adjustment layer.

Anybody have any luck with this?

(Edit: more info)

TOPICS
Actions and scripting

Views

8.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Oct 11, 2013 Oct 11, 2013

Another route could be this function that lets you specify inputWhite, inputBlack, gamma, outputWhite, outputBlack

setLevelAdj = function(inBlack, inWhite, gamma, outBlack, outWhite) {

  var d, d1, d2, l, l1, l2, r, r1, s2t;

  if (outBlack == null) {

    outBlack = 0;

  }

  if (outWhite == null) {

    outWhite = 255;

  }

  s2t = function(s) {

    return app.stringIDToTypeID(s);

  };

  d = new ActionDescriptor();

  r = new ActionReference();

  r.putEnumerated(s2t('adjustmentLayer'), s2t('ordinal'), s2t('target

...

Votes

Translate

Translate
Adobe
Advocate ,
Oct 11, 2013 Oct 11, 2013

Copy link to clipboard

Copied

Another route could be this function that lets you specify inputWhite, inputBlack, gamma, outputWhite, outputBlack

setLevelAdj = function(inBlack, inWhite, gamma, outBlack, outWhite) {

  var d, d1, d2, l, l1, l2, r, r1, s2t;

  if (outBlack == null) {

    outBlack = 0;

  }

  if (outWhite == null) {

    outWhite = 255;

  }

  s2t = function(s) {

    return app.stringIDToTypeID(s);

  };

  d = new ActionDescriptor();

  r = new ActionReference();

  r.putEnumerated(s2t('adjustmentLayer'), s2t('ordinal'), s2t('targetEnum'));

  d.putReference(s2t('target'), r);

  d1 = new ActionDescriptor();

  d1.putEnumerated(s2t('presetKind'), s2t('presetKindType'), s2t('presetKindCustom'));

  l = new ActionList();

  d2 = new ActionDescriptor();

  r1 = new ActionReference();

  r1.putEnumerated(s2t('channel'), s2t('channel'), s2t('composite'));

  d2.putReference(s2t('channel'), r1);

  l1 = new ActionList();

  l1.putInteger(inBlack);

  l1.putInteger(inWhite);

  d2.putList(s2t('input'), l1);

  d2.putDouble(s2t('gamma'), gamma);

  l2 = new ActionList();

  l2.putInteger(outBlack);

  l2.putInteger(outWhite);

  d2.putList(s2t('output'), l2);

  l.putObject(s2t('levelsAdjustment'), d2);

  d1.putList(s2t('adjustment'), l);

  d.putObject(s2t('to'), s2t('levels'), d1);

  return executeAction(s2t('set'), d, DialogModes.NO);

};

Davide

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Oct 11, 2013 Oct 11, 2013

Copy link to clipboard

Copied

I may have mis-understood and made things more complex than needed. I thought if the op wanted to modify an existing levels adjustment layer they would want to get the existing settings.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 11, 2013 Oct 11, 2013

Copy link to clipboard

Copied

Mike,

how have you been able to get to that, does it comes from the PS file formats specs? (i.e.saved presets for Layers adjustments)

I've never been confortable with data stream, yet I'm willing to learn.

Well done!

Davide

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Oct 11, 2013 Oct 11, 2013

Copy link to clipboard

Copied

First I wrote the data to a file after getting it from the layer descriptor. I then used a hexeditor to compare that file to the levels .alv file spec. It looked the same so I just followed the structure.

If you want to try working with binary data like this I strongly suggest that you do not run/test the code using ESTK. It will hang and you will have to close ESTK and Photoshop. I use ESTK most of the time when I am working on a script because of it's features. But after loosing work countless times because of a hang I now use a different editor and test run the script using the Photoshop File-Scripts-Browse menuItem.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 11, 2018 Mar 11, 2018

Copy link to clipboard

Copied

If you want to try working with binary data like this I strongly suggest that you do not run/test the code using ESTK. It will hang and you will have to close ESTK and Photoshop.

For those having same problem as Michael L Hale while don't want to use other editor, put any code reading binaries into:

(function(){

    //    his/your script

})()

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 11, 2013 Oct 11, 2013

Copy link to clipboard

Copied

That's exactly what I'm looking for. Thank you Davide.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 08, 2015 Sep 08, 2015

Copy link to clipboard

Copied

I guess i was lucky and after several try the script listener did pick up the settings of the levels adjustment layer setting.

I saw some code up here, but it didnt worked for me (maybe cos different version?! i dont know)


So here is the result >>

(i put some comment where the adjustable variables are)

var idsetd = charIDToTypeID( "setd" );

    var desc5 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref2 = new ActionReference();

        var idAdjL = charIDToTypeID( "AdjL" );

        var idOrdn = charIDToTypeID( "Ordn" );

        var idTrgt = charIDToTypeID( "Trgt" );

        ref2.putEnumerated( idAdjL, idOrdn, idTrgt );

    desc5.putReference( idnull, ref2 );

    var idT = charIDToTypeID( "T   " );

        var desc6 = new ActionDescriptor();

        var idpresetKind = stringIDToTypeID( "presetKind" );

        var idpresetKindType = stringIDToTypeID( "presetKindType" );

        var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );

        desc6.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );

        var idAdjs = charIDToTypeID( "Adjs" );

            var list1 = new ActionList();

                var desc7 = new ActionDescriptor();

                var idChnl = charIDToTypeID( "Chnl" );

                    var ref3 = new ActionReference();

                    var idChnl = charIDToTypeID( "Chnl" );

                    var idChnl = charIDToTypeID( "Chnl" );

                    var idCmps = charIDToTypeID( "Cmps" );

                    ref3.putEnumerated( idChnl, idChnl, idCmps );

                desc7.putReference( idChnl, ref3 );

                var idInpt = charIDToTypeID( "Inpt" );

                    var list2 = new ActionList();

                    list2.putInteger( 0 );     // Black point

                    list2.putInteger( 240 );  // White point

                desc7.putList( idInpt, list2 );

                var idGmm = charIDToTypeID( "Gmm " );

                desc7.putDouble( idGmm, 1.30 );  //Gamma point

            var idLvlA = charIDToTypeID( "LvlA" );

            list1.putObject( idLvlA, desc7 );

        desc6.putList( idAdjs, list1 );

    var idLvls = charIDToTypeID( "Lvls" );

    desc5.putObject( idT, idLvls, desc6 );

executeAction( idsetd, desc5, DialogModes.NO );

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 11, 2018 Mar 11, 2018

Copy link to clipboard

Copied

That's probably bug. To force ScriptListener to record changes made to Adjustment Layer you have for example to choose / create other layer. When you then open SL log you will find 2 new records while the 1st refers changes to Adjustment Layer.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines