3 Replies Latest reply on Oct 17, 2013 5:08 AM by Michael L Hale

    Getting bounds error.

    _VG Level 1

      Hi All,

       

      I am writing a script to get the height and width of the layer.

      I am getting the bounds of the layer and calculate the width and height.

       

      Now when I try to get the bounds of layer with effect applied on that layer. I am getting incorrect bounds.

       

      Is this a bug in photoshop or am I missing something?

       

      Is there any appropriate solution for calculating the bounds of layer if effect is applied on that layer.

       

      Effect could be stroke, drop shadow, inner shadow etc.

       

      Thanks..

        • 1. Re: Getting bounds error.
          Michael L Hale Level 5

          I don't know if it is a bug or not but it has been that way until Photoshop CC. Really it still is that way, CC added a new property to artLayer that will let you get the bounds without effects.

           

          app.activeDocument.activeLayer.boundsNoEffects

           

          If you don't have CC you need to turn off the layer effects before getting the bounds. Note not all layer effects change the bounds but it is easier just to turn the effects off as a group.

          • 2. Re: Getting bounds error.
            _VG Level 1

            Thanks for the reply Michael,

             

            But I need to get the bounds with effects on it.

            Let's say we apply stroke to an object. Now the height and width of that layer changed.

            I need to get the correct bounds of that layer with stroke applied on it..

            Is there any solution for this?

             

            Thanks.

            • 3. Re: Getting bounds error.
              Michael L Hale Level 5

              What version of Photoshop are you using? In every version I remember the bounds included layer effects if the effect changes bounds. For example a 3px inter stroke effect would not change the bounds but that same size storke set to center or outer would change the bounds.

               

              So you should not need to do any extra steps to get the bounds that include the effects. app.activeDocument.activeLayer.bounds will give you the bounds with the effects applied.