8 Replies Latest reply on Feb 8, 2012 9:06 PM by Michael L Hale

    Adjustment Layers


           I am trying to create a script that will copy and paste, essentially, the attributes of adjustment layers.  I have been unable to find a great deal of information on this on the web, forums and the javascript ref guide. Is there a one size fits all approach to this or does each adj. layer have to be done differently according to that layers information.

        • 1. Re: Adjustment Layers
          JJMack Most Valuable Participant

          Could you give us more details of what your trying to do. Copy and Paste uses the clipboard which I thinks supports text and image.  What did you mean whe you wrote "copy and paste essentially, the attributes of adjustment layers"

          • 2. Re: Adjustment Layers
            Clevadio Level 1

            My apologies I mean read/write. I want to read the attributes of one adjustment layer and write them to another adjustment layer.

            • 3. Re: Adjustment Layers
              JJMack Most Valuable Participant

              If you do not see a method in the Photoshop scripting guide that provides this function you may need to go to extraordinary length to get information about a layer. Do a search here on how to find information about layers.  I think I have seen some threads on this subject look for replies from Mike Hale and Paul Riggott their knowledge is extensive and they include many scripting examples in their appends.


              • 4. Re: Adjustment Layers
                c.pfaffenbichler Level 9

                But apart from the ActionDescriptor-route (which has, as JJMack hinted at, probably be fairly invilved) why do you want to do that anyway?

                Would simply duplicating the Adjustment Layer and moving it to the proper position not work?

                1 person found this helpful
                • 5. Re: Adjustment Layers
                  Clevadio Level 1

                  I am creating a script that will syncronize documents and when I come to an adjustment layer I want to be able to read the attributes of that layer then write them to the other documents layers.  At this time I just have the script duplicating the layer and removing the old layer.  I am fine with my current method I was just curious if there was a method for, essentially, copy/pasting adjustment layer attributes like layer effects. Thanks for all your help everyone. I'll piece it together as time goes on and post the finished result.

                  • 6. Re: Adjustment Layers
                    Michael L Hale Level 5

                    To find some of the setting of an adjustment layer you need to use Action Manager. Each adjustment has an Action Descriptor that has different properties so you would have to have code for each type of adjustment you want to work with. Also somewhere around CS3 or CS4 Adobe changed the way the adjustment layers store their data. That means that you have to have different code for each layer type if you want to support multiple versions of Photoshop. To make things worse in the new versions it is much hard to get the setting as they are stored as raw data. And some settings like blend-if can not be read via scripting.

                    1 person found this helpful
                    • 7. Re: Adjustment Layers
                      Clevadio Level 1


                         Thanks for the information. It is definitely helpful. I didn't think this would be something that would be easy to do.

                      • 8. Re: Adjustment Layers
                        Michael L Hale Level 5

                        Well you have to really what the info to put in the effort to get the information out of an adjustment layer. For one think if there is any public documention on the adjustment layer structure I have not found it.


                        But to give you an example, here is how I get the info for a hue/sat layer( one of the adjustments that store the setting in raw data )


                        function getHueSatAdjustment(){     
                              var ref = new ActionReference();
                             ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
                             var desc = executeActionGet(ref).getList(stringIDToTypeID('adjustment')).getObjectValue(0);
                             var rawData = desc.getData(stringIDToTypeID('legacyContentData'));
                              var hueSatAdjustment = {};
                              hueSatAdjustment.isColorized = Boolean(readInteger(rawData, 2));
                                 hueSatAdjustment.colorized = {};
                               hueSatAdjustment.colorized.hue = readAngle(rawData, 4);
                               hueSatAdjustment.colorized.sat = readInteger(rawData, 6);
                               hueSatAdjustment.colorized.brightness = readInteger(rawData, 8);
                               hueSatAdjustment.master = {};
                               hueSatAdjustment.master.hue = readInteger(rawData, 10);
                               hueSatAdjustment.master.sat = readInteger(rawData, 12);
                               hueSatAdjustment.master.brightness = readInteger(rawData, 14);
                               hueSatAdjustment.reds = {};
                               hueSatAdjustment.reds.beginRamp = readInteger(rawData, 16);
                               hueSatAdjustment.reds.beginSustain = readInteger(rawData, 18);
                               hueSatAdjustment.reds.endSustain = readInteger(rawData, 20);
                               hueSatAdjustment.reds.endRamp = readInteger(rawData, 22);
                               hueSatAdjustment.reds.hue = readInteger(rawData, 24);
                               hueSatAdjustment.reds.sat = readInteger(rawData, 26);
                               hueSatAdjustment.reds.brightness = readInteger(rawData, 28);
                               hueSatAdjustment.yellows = {};
                               hueSatAdjustment.yellows.beginRamp = readInteger(rawData, 30);
                               hueSatAdjustment.yellows.beginSustain = readInteger(rawData, 32);
                               hueSatAdjustment.yellows.endSustain = readInteger(rawData, 34);
                               hueSatAdjustment.yellows.endRamp = readInteger(rawData, 36);
                               hueSatAdjustment.yellows.hue = readInteger(rawData, 38);
                               hueSatAdjustment.yellows.sat = readInteger(rawData, 40);
                               hueSatAdjustment.yellows.brightness = readInteger(rawData, 42);
                               hueSatAdjustment.greens = {};
                               hueSatAdjustment.greens.beginRamp = readInteger(rawData, 44);
                               hueSatAdjustment.greens.beginSustain = readInteger(rawData, 46);
                               hueSatAdjustment.greens.endSustain = readInteger(rawData, 48);
                               hueSatAdjustment.greens.endRamp = readInteger(rawData, 50);
                               hueSatAdjustment.greens.hue = readInteger(rawData, 52);
                               hueSatAdjustment.greens.sat = readInteger(rawData, 54);
                               hueSatAdjustment.greens.brightness = readInteger(rawData, 56);
                               hueSatAdjustment.cyans = {};
                               hueSatAdjustment.cyans.beginRamp = readInteger(rawData, 58);
                               hueSatAdjustment.cyans.beginSustain = readInteger(rawData, 60);
                               hueSatAdjustment.cyans.endSustain = readInteger(rawData, 62);
                               hueSatAdjustment.cyans.endRamp = readInteger(rawData, 64);
                               hueSatAdjustment.cyans.hue = readInteger(rawData, 66);
                               hueSatAdjustment.cyans.sat = readInteger(rawData, 68);
                               hueSatAdjustment.cyans.brightness = readInteger(rawData, 70);
                                  hueSatAdjustment.blues = {};
                                  hueSatAdjustment.blues.beginRamp = readInteger(rawData, 72);
                               hueSatAdjustment.blues.beginSustain = readInteger(rawData, 74);
                               hueSatAdjustment.blues.endSustain = readInteger(rawData, 76);
                               hueSatAdjustment.blues.endRamp = readInteger(rawData, 78);
                               hueSatAdjustment.blues.hue = readInteger(rawData, 80);
                               hueSatAdjustment.blues.sat = readInteger(rawData, 82);
                               hueSatAdjustment.blues.brightness = readInteger(rawData, 84);
                               hueSatAdjustment.magentas = {};
                               hueSatAdjustment.magentas.beginRamp = readInteger(rawData, 86);
                               hueSatAdjustment.magentas.beginSustain = readInteger(rawData, 88);
                               hueSatAdjustment.magentas.endSustain = readInteger(rawData, 90);
                               hueSatAdjustment.magentas.endRamp = readInteger(rawData, 92);       
                               hueSatAdjustment.magentas.hue = readInteger(rawData, 94);
                               hueSatAdjustment.magentas.sat = readInteger(rawData, 96);
                               hueSatAdjustment.magentas.brightness = readInteger(rawData, 98);
                               return hueSatAdjustment;
                        function readInteger(str, pointer) { //aka signed word = 2 bytes in big-endian byte order
                            var byte1 = str.charCodeAt(pointer);
                            var byte2 = str.charCodeAt(pointer + 1);
                            var singedsShort = (byte1 <<8) + byte2;
                            if (singedsShort > 0x7FFF) {
                                singedsShort = 0xFFFF0000 ^ singedsShort;
                            return singedsShort;
                        function readAngle(str, pointer) { 
                            var b1 = str.charCodeAt(pointer);
                            var b2 = str.charCodeAt(pointer+1);
                                var ss = b2;
                                var ss = b2+104;//???
                          return ss;