1 Reply Latest reply on Mar 22, 2014 3:55 AM by c.pfaffenbichler

    How to determine if a layer was flipped or rotated

    dgadobe1

      I'm loooking for a way to determine if a layer has been flipped or rotated.  I found this code in a post that gets the rotation for a text layer, but I'm not able to adapt it to other layer types (e.g. art layers or smart objects) or to determine if the layer has been flipped.  Any help or pointers would be greatly appreciated!

       

       

      function getActiveLayerRotation()

      {

          var ref = new ActionReference();

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

         

          var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID('textKey'));

          if (desc.hasKey(stringIDToTypeID('transform')))

          {

              desc = desc.getObjectValue(stringIDToTypeID('transform'));

              var yy = desc.getDouble(stringIDToTypeID('yy'));

              var xy = desc.getDouble(stringIDToTypeID('xy'));

              var angle =  angleFromMatrix(yy, xy);      

              return angle;    

          }

      }

       

      function angleFromMatrix(yy, xy)

      {

          var toDegs = 180/Math.PI;

          return Math.atan2(yy, xy) * toDegs - 90;

      }

        • 1. Re: How to determine if a layer was flipped or rotated
          c.pfaffenbichler Level 9

          Evaluating transformation values for Smart Objects has proven elusive for Scripting so far to the best of my knowledge.

           

          And plain ArtLayers have no such »memory« as they simply contain the pixels that result from the transformation.

          If you have a duplicate of the untransformed Layer one might be able to concoct a complicated Scripting approach, but that seems a bit excessive.