3 Replies Latest reply on Jan 4, 2012 9:33 AM by Michael L Hale

    Layer effects Info

    Domaneni Level 1

      Hi,

      a week ago I asked about the number of effects: http://forums.adobe.com/message/4094949#4094949

      And today I would like to deepen the problem. I need to find all the information about each effect. So how is the effect of each set.

       

      Do you know some resolution??

       

      Thanks Domaneni

        • 1. Re: Layer effects Info
          Michael L Hale Level 5

          There are a lot of effects and most have a lot of settings. For example the function below gets the settings for a layer's dropshadow effect. It stores the settings in a custom object with over a dozen properties and it still does not get all the dropshadow settings.

          getDropShadowSettings();
          function getDropShadowSettings(){
              var ref = new ActionReference();
              ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
              var layerDesc = executeActionGet(ref);
              if(layerDesc.hasKey(charIDToTypeID("Lefx"))){
                  var effectDesc = layerDesc.getObjectValue(charIDToTypeID("Lefx"));
                  if(effectDesc.hasKey(charIDToTypeID("DrSh"))){
                      var dropShadowDesc = effectDesc.getObjectValue(charIDToTypeID("DrSh"));
                      var dropShadow = {};
                      dropShadow.toString = function(){return "Drop shadow effect settings";}
                      dropShadow.enabled = dropShadowDesc .getBoolean( charIDToTypeID( "enab" ));
                      dropShadow.blendMode = typeIDToStringID(dropShadowDesc .getEnumerationValue(charIDToTypeID( "Md  " )));
                      var shadowColorDesc = dropShadowDesc .getObjectValue(charIDToTypeID( "Clr " ));
                      var shadowColorMode = typeIDToCharID(dropShadowDesc .getObjectType(charIDToTypeID( "Clr " )));
                      dropShadow.color  = new SolidColor();
                      switch ( shadowColorMode ){
                          case 'Grsc':
                              dropShadow.color.gray.gray = shadowColorDesc.getDouble(charIDToTypeID('Gry '));
                              break;
                          case 'RGBC':
                               dropShadow.color.rgb.red = shadowColorDesc.getDouble(charIDToTypeID('Rd  '));
                              dropShadow.color.rgb.green = shadowColorDesc.getDouble(charIDToTypeID('Grn '));
                              dropShadow.color.rgb.blue = shadowColorDesc.getDouble(charIDToTypeID('Bl  '));
                              break;
                          case 'CMYC':
                              dropShadow.color.cmyk.cyan = shadowColorDesc.getDouble(charIDToTypeID('Cyn '));
                              dropShadow.color.cmyk.magenta = shadowColorDesc.getDouble(charIDToTypeID('Mgnt'));
                              dropShadow.color.cmyk.yellow = shadowColorDesc.getDouble(charIDToTypeID('Ylw '));
                              dropShadow.color.cmyk.black = shadowColorDesc.getDouble(charIDToTypeID('Blck'));
                              break;
                          case 'LbCl':
                              dropShadow.color.lab.l = shadowColorDesc.getDouble(charIDToTypeID('Lmnc'));
                              dropShadow.color.lab.a = shadowColorDesc.getDouble(charIDToTypeID('A   '));
                              dropShadow.color.lab.b = shadowColorDesc.getDouble(charIDToTypeID('B   '));
                              break;
                      }                        
                      dropShadow.opacity = dropShadowDesc .getDouble(charIDToTypeID("Opct"));
                      dropShadow.useGlobalAngle = dropShadowDesc .getBoolean(charIDToTypeID("uglg"));
                      dropShadow.localLightingAngle  = dropShadowDesc .getDouble( charIDToTypeID( "lagl" ));
                      dropShadow.distance = dropShadowDesc .getDouble( charIDToTypeID( "Dstn" ));
                      dropShadow.spread = dropShadowDesc .getDouble( charIDToTypeID( "Ckmt" ));
                      dropShadow.blur =  dropShadowDesc .getDouble( charIDToTypeID( "blur" ));
                      dropShadow.noise = dropShadowDesc .getDouble( charIDToTypeID( "Nose" ));
                      dropShadow.antialias = dropShadowDesc .getBoolean( charIDToTypeID( "AntA" ));
                      dropShadow.knockout = dropShadowDesc .getBoolean( stringIDToTypeID( "layerConceals" ));
                      var contourDesc = dropShadowDesc .getObjectValue( charIDToTypeID( "TrnS" ), charIDToTypeID( "ShpC" ) );
                      if( contourDesc.hasKey(charIDToTypeID("Nm  ")) ) {
                          dropShadow.contourName = localize(contourDesc.getString( charIDToTypeID( "Nm  "  )));
                      }else{
                          dropShadow.contourName = 'custom';
                      }
                      return dropShadow;
                  }
              }
          }
          

           

          Are you looking to find info about a specific effect? What do you want to do with the info?

          • 2. Re: Layer effects Info
            boris.suska

            Hi, I'm a Domaneni co-worker.

            We're trying to write Photoshop script for getting informations about effects of selected layer. Later we would like to write new Create layers function (from layer effects) because current function doesn't work with opacity correctly. Until this future feature we would like to recognize by effect attributes if it is possible to convert effects to layers without visually changes.

            getDropShadowSettings function looks good and we would like to write similar functions for each non-correctly translated effect in future. How do you know which properties to get from dropShadowDesc property? We're using ScriptListener to identify how to call PS function from JavaScript, but we don't know how to identify structeres and its properties. Do you have any hints for us, how to do that?

            • 3. Re: Layer effects Info
              Michael L Hale Level 5

              There are two ways that I know of to explore an Action Descriptor. One way is to use Xbytor's getterdemo.jsx ( found in his xtools ). That script has a custom UI where you can choose from several common classes such as document, layer, etc. It exports the entire descriptor as XML. It is great when learning about Action Manager programming because everything is included and nicely formatted. The downside is it can sometimes output too much info. Especially once you are familiar with Action Descriptors, Action Lists, and how to work with them.

               

              So I like to use a small script I will post below that is much more interactive. It takes some knowledge of working with Action Manager but you can limit the output to just want you are interested in exploring and it outputs to the Javascript Console in ESTK. You create an Action Reference to the object you what to explore and the script outputs the keys and data types it finds. For example the script as it appears below with list the keys in a selected layer's Action Descriptor.

               

               

              var ref = new ActionReference();
              ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
              var desc = executeActionGet(ref);
              $.writeln( desc );
              
              if(desc.typename == 'ActionReference'){
                  var c = desc.count;
                  for(var i=0;i<c;i++){ //enumerate reference. use getForm() to determine which get method to use
                    $.writeln('Key '+zeroPad( i+1, 2 )+' = '+desc.getReference(i).getIndex()); 
                  }
              }
              
              if(desc.typename == 'ActionList'){
                  var c = desc.count;
                  for(var i=0;i<c;i++){ //enumerate list
                    $.writeln('Key '+zeroPad( i+1, 2 )+' = '+desc.getType(i));
                  }
              }
              if(desc.typename == 'ActionDescriptor'){
                  var c = desc.count;
                  for(var i=0;i<c;i++){ //enumerate descriptor's keys
                    $.writeln('Key '+zeroPad( i+1, 2 )+' = '+IDTz(desc.getKey(i))+' : '+desc.getType(desc.getKey(i))); 
                  }
              }
              function IDTz(id){
                  var isCharID = false;
                  try {
                      if( new String( id ).length == 10 ) {
                          isCharID = true;
                          var charID = '"'+typeIDToCharID( id )+'"';
                          var stringID = '"'+typeIDToStringID( id )+'"';
                          if( stringID.length <=2 ) {
                              stringID = '  NA   ';
                          }else{
                              while( stringID.length < 25 ){
                              stringID += ' ';
                              }
                          }
                      }else{
                          var charID = ' NA  ';
                          var stringID = '"'+typeIDToStringID( id )+'"';
                          while( stringID.length < 25 ){
                              stringID += ' ';
                          }
                      }
                  }catch(e){}
                  return charID+' | '+stringID;
              }
              function zeroPad(num,pad) {
                   var z = Math.pow(10,Number(pad))
                   return num <= z ? ((Number( num) + z).toString().substr(1)): num
              }
              

              From there you can drill down to find just the data you want. For example when you run the script above with a layer that has a layer effect you will see that one of the layer's Action Descriptor keys has a charID of "Lefx" and an object datatype( it is another Action Descriptor ). You can then change

              var desc = executeActionGet(ref);

              to

              var desc = executeActionGet(ref).getObjectValue(charIDToTypeID("Lefx"));

              and explore the effects descriptor. If the layer has a stroke effect you can edit the same line and now only get info about the stroke.

              var desc = executeActionGet(ref).getObjectValue(charIDToTypeID("Lefx")).getObjectValue(charIDToTypeI D("FrFX"));

               

              If I run that with a layer that has a color stroke effect I see that there are 7 keys in the Action Descriptor. A gradient stroke has 14 keys.

               

              That is basically how I created the dropshodow function. Except I split the like getting the descriptor up so I could use hasKey() to avoid errors. i.e. if a layer does not have an effect it will not have a key with the charID "Lefx".