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

How to access and change any adjustment layer properties after created

Participant ,
Jun 06, 2018 Jun 06, 2018

Copy link to clipboard

Copied

Hello! I've been searching a way to access adjustment layers properties after created in the layers section, however I've failed with the ScriptListener pluging, which seems not to record that action. But I know there would be a way to access there via Action Manager, I have faith on that haha! This Action Manager language makes me happier everytime I learn something new about it. I think I found a cure for my anxiety!

TOPICS
Actions and scripting

Views

3.2K

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
Adobe
Advocate ,
Jun 06, 2018 Jun 06, 2018

Copy link to clipboard

Copied

you have to convert the level to an advanced object

and then change the level properties.

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
Explorer ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

here is a link to code from Mike Hale which could help solve your problem.

I haven't used it yet, but I think with some modifications you should be able to use this stuff.

http://ps-scripts.com/bb/viewtopic.php?p=10945

btw there are several posts in ps-scripts.com referring to acv-files. They may be helpful too.

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 ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

After I click that link I'm ending on ps-scripts site but recieving The requested topic does not exist. information.

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
Explorer ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

I have the same problem trying to click on links of ps-scripts.com. I suppose that the content to these links is hidden deep in the archives and no longer available.

But here follows the code Mike Hale published some years ago:

#target photoshop

// Here is a sample script that will save an acv file from an existing curves adjustment layer.

// The script expects the adjustment layer to be the active layer and I only tested

// with RGB 8bit images on Windows

File.prototype.writeByte = function(b) { this.write(String.fromCharCode(b)) };

File.prototype.writeShort = function(ET,s) {

    var self = this;

    if(ET == "BE"){

        self.writeByte(s & 0xFF);

        self.writeByte((s >> 8) & 0xFF);

    }else{

        self.writeByte((s >> 8) & 0xFF);

        self.writeByte(s & 0xFF);

    }

    return self;

};

convertBCD = function( num ){

    if(num == 13) { return [1,1,0,1] };// special case

  

    var res = new Array;

    if(num > 8 ){

        res.unshift(1);

        num = num - 8;

    }else{

        res.unshift(0);

    }

    if(num > 4 ){

        res.unshift(1);

        num = num - 4;

    }else{

        res.unshift(0);

    }

    if(num > 2 ){

        res.unshift(1);

        num = num - 2;

    }else{

        res.unshift(0);

    }

    if(num == 1 ){

        res.unshift(1);

    }else{

        res.unshift(0);

    }

    return res;

};

getCurve = function( numberOfPoints ){

    this.getPoints = function(){

        this.tempArray = new Array;

        this.tempArray.push( rawDesc.charCodeAt( pointer ) );

        pointer = pointer + 2;// set pointer to next point

        this.tempArray.push( rawDesc.charCodeAt( pointer ) );

        return this.tempArray;

    }

  

   this.pointsArray = new Array;

   for( var i = 0; i < numberOfPoints; i++ ){

      pointer = pointer + 2;// next point

      this.pointsArray.push( this.getPoints() );

   }

   pointer = pointer + 2;// next curve

   return this.pointsArray;

};

var ref = new ActionReference();

ref.putEnumerated( charIDToTypeID( 'Lyr ' ), charIDToTypeID( 'Ordn' ), charIDToTypeID( 'Trgt' ) );

var rawDesc = executeActionGet( ref ).getList( stringIDToTypeID( 'adjustment' ) ).getObjectValue( 0 ).getData( stringIDToTypeID( 'legacyContentData' ) );

var pointer = 2;                                            // used to read rawData similar to reading a file

var flag = rawDesc.charCodeAt( pointer );       // char at offset 2 always == 1 so use to validate data

if( flag != 1 ) forceError;                             // unknown problem with rawData

   pointer = 6;// update pointer to BCD byte

   var bcd = rawDesc.charCodeAt( pointer );

   if( bcd < 0 || bcd > 15 ) forceError;// check for valid value

   if( bcd == 0 ) forceError;// an empty adjustment - no curves to process

   var bcdArray = convertBCD( bcd );

   var numberOfCurves = bcdArray.toString().match(/(1)/g).length;

   var curvesArray = new Array;

   pointer = 8;// set pointer to start of curve data

   for(var i = 0; i < numberOfCurves; i++ ){

      var numberOfPoints = rawDesc.charCodeAt( pointer );

      curvesArray.push( getCurve( numberOfPoints ) );

   }

// now need to map rawData curves in curvesArray to known channel curves

// for example if bcd == 7 then there is a RGB, RED, and GREEN curve

// if bcd ==  8 then there is only a BLUE curve. etc

var acvArray = new Array;

if( bcdArray[0] == 1 ) {

   acvArray.push( curvesArray.shift() );

} else {

   acvArray.push( [ [0,0],[255,255] ] );

}

if( bcdArray[1] == 1 ) {

   acvArray.push( curvesArray.shift() );

} else {

   acvArray.push( [ [0,0],[255,255] ] );

}

if( bcdArray[2] == 1 ) {

   acvArray.push( curvesArray.shift() );

} else {

   acvArray.push( [ [0,0],[255,255] ] );

}

if( bcdArray[3] == 1 ) {

   acvArray.push( curvesArray.shift() );

} else {

   acvArray.push( [ [0,0],[255,255] ] );

}

acvArray.push( [ [0,0],[255,255] ] );

// Write to acv-File

var myACV = new File('~/Desktop/myCurve.acv');

myACV.open('w');

myACV.writeShort( 'LE','4' );// acv header

myACV.writeShort( 'LE','5' );// acv header

for( var i = 0; i< 5; i++ ) {

   var numberOfPoints = acvArray.length;

   myACV.writeShort( 'LE', numberOfPoints.toString() );

   //myACV.writeByte( 0 );

   for( var p = 0; p < numberOfPoints; p++ ){

      myACV.writeShort( 'LE', acvArray

[0].toString() );

      myACV.writeShort( 'LE', acvArray

[1].toString() );

   }

}

content = myACV.read()

myACV.close();

'Mike Hale '

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 ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

True - all Ps-Scripts links I clicked last month that normally have been taking me to appropriate topics do not work. What is wired, even those correct ones I would post now do not display right pages 😕 There is also other change on that forums. All codes I posted with indentations are seen without them (so all scripts lines start in the same first column).

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
People's Champ ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

What kind of adjustment layer data do you want to read or change? Different types of layers contain different data.
For the "Levels" type, you can examine this code.

Re: Modifying Levels 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
Community Expert ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

Also about the scriptlistener or recording things done in Photoshop.  Some things that are recorded are recorded in a delayed fashion.  That is while you making some adjustments nothing is recorder. So you can make many trial adjustments till you find the one that suites you.  When you move on to your next Photoshop step.  Photoshop will record the last adjustment you made for your previous step.   That way only the adjustment you want is recorded.  So if you had a problem with Scriptlistener not recording your Adjustment it is very likely it was in delayed recording mode waiting for you to move on to your next Photoshop function.  Some times you need to move on for a step to be recorded. 

JJMack

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
Participant ,
Jun 09, 2018 Jun 09, 2018

Copy link to clipboard

Copied

Guys, I appreciate a lot your help! I found a very easy way to do it, this study helped me to understand better Action Managers behavior ! It is so exciting learning this stuff tho!

First Irecorded with script listener a brightness and contrast adjustment directly into a layer. Studied the settings and how they were applied with which action descriptor, seems Actions Manager actions works hierarchically, so I just simplified variables and stuff.

Then I recorded again with script listener how an adjustment layer is created with Action Manager but added another action descriptor in the hierarchy to with the settings of the adjustment layers, seems to work the same for everyone of them.

Also found that putInteger() and putDouble() works the same haha!

Here is the code I built to create and adjustment layer with the desired settings, i tried some stuff also with random values to have differente results


What this code does is it creates a ColorBalance adjustment layer with randome balues on the different levels, and it checks if there´s any layer name "NewColorBalance", if so, it removes that layer and creates another ColorBalance adjustment layer with random settings.

If you rename the layer, it creates another adjustment layer and name it NewColorBalance.

function colorBalanceAdjLayer) {

var layLen = app.activeDocument.layers;

var actLayer = app.activeDocument.activeLayer;

var i;

for (i = 0; i < layLen.length; i++) {

if (layLen.name == "NewColorBalance") {

app.activeDocument.layers.getByName("NewColorBalance").remove();

}

}

function s2t(s) { return app.stringIDToTypeID(s) }

//Declaring variables////////////////////////////////////////////////////////////////////////////////////////////////

var ranD1 = Math.floor(Math.random() * (10 - 0 + 1) ) + 0

var ranD2 = Math.floor(Math.random() * (10 - (-10) + 1) ) + -10

var ranD3 = Math.floor(Math.random() * (0 - (-10) + 1) ) + -10

var ranD4 = Math.floor(Math.random() * (10 - (-10) + 1) ) + -10

var ranD5 = Math.floor(Math.random() * (10 - (-10) + 1) ) + -10

var ranD6 = Math.floor(Math.random() * (10 - (-10) + 1) ) + -10

var ranD7 = Math.floor(Math.random() * (0 - (-20) + 1) ) + -20

var ranD8 = Math.floor(Math.random() * (10 - (-10) + 1) ) + -10

var ranD9 = Math.floor(Math.random() * (10 - 0 + 1) ) + 0

var d1 = new ActionDescriptor();

var d2 = new ActionDescriptor();

var aRef = new ActionReference();

var d3 = new ActionDescriptor();

var d4 = new ActionDescriptor();

var d5 = new ActionDescriptor();

var l1 = new ActionList();

var l2 = new ActionList();

var l3 = new ActionList();

// Class of what is MADE////////////////////////////////////////////////////////////////////////////////////////

aRef.putClass( s2t( "adjustmentLayer" ) );

d1.putReference( s2t( "null" ), aRef );

//===============================================================

//===============================================================

//Adjustment layer properties////////////////////////////////////////////////////////////////////////////////

l3.putInteger( ranD1 );

l3.putInteger( ranD2 );

l3.putInteger( ranD3 );

d3.putList( s2t("shadowLevels"), l3 );

l2.putInteger( ranD4 );

l2.putInteger( ranD5 );

l2.putInteger( ranD6 );

d3.putList( s2t("midtoneLevels"), l2 );

l1.putInteger( ranD7 );

l1.putInteger( ranD8 );

l1.putInteger( ranD9 );

d3.putList( s2t("highlightLevels"), l1 );

d3.putBoolean( s2t("preserveLuminosity"), true);

//Type of adjustment layer//////////////////////////////////////////////////////////////////////////////////////

d2.putObject( s2t( "type" ), s2t( "colorBalance" ), d3 );

//===============================================================

//===============================================================

d1.putObject( s2t( "using" ), s2t( "adjustmentLayer" ), d2 );

//CREATE ADJUSTMENT LAYER ACTION///////////////////////////////////////////////////////////////

executeAction( s2t( "make" ), d1, DialogModes.NO );

// First step is to MAKE the object

app.activeDocument.activeLayer.name = "NewColorBalance"

}

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
People's Champ ,
Jun 11, 2018 Jun 11, 2018

Copy link to clipboard

Copied

LATEST

olverart


Also found that putInteger() and putDouble() works the same haha!

You are wrong.

If you replace the

desc.putDouble( charIDToTypeID( "Gmm " ), gm );

with

desc.putInteger( charIDToTypeID( "Gmm " ), gm );

in the function edit_levels() of this post, Re: Modifying Levels Adjustment Layer?

then nothing good you will get

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