Skip to main content
Known Participant
September 8, 2014
Question

Layer bounds are wrong. How to fix?

  • September 8, 2014
  • 2 replies
  • 671 views

I'm trying to get the X, Y positions of a layer using layerRef.bounds. However, when the layer is a vector shape, the values returned are wrong by one or two pixels.


This happens in CS5 and CS6, but the correct values are returned in CC.

What is a way around this to make it work in CS5 and CS6?

Thanks!

This topic has been closed for replies.

2 replies

JJMack
Community Expert
Community Expert
September 9, 2014

To work around the problem in cs5 and Cs6 you could try creating a temp work layer for shape layers like it but not a shape.  Dupe the layer, rastezise the layer and check if its bounds are what you want. then delete the work layer.

JJMack
rixter123Author
Known Participant
September 9, 2014

Thanks JJMack for the answer! I was hoping there was a less messy way to deal with it.

What I'm doing currently is: my workflow involves trimming the layers to their contents. I take the bounds before and after trimming and calculate the correct bounds.

c.pfaffenbichler
Community Expert
Community Expert
September 8, 2014

Can you provide the files?

rixter123Author
Known Participant
September 9, 2014

Here's a file: https://dl.dropboxusercontent.com/u/3901152/bounds.psd

The X,Y positions of the shape's top-left corner are 185px and 269px according to Photoshop. But the bounds function gives them as 184 and 268. (Both CS5 and CS6)

The bounds of Layer 1 (which is just a brush stroke) are returned properly.

JJMack
Community Expert
Community Expert
September 9, 2014

It may depend on the CS6 version there are 3 Perpetual Mac is version 13.0.6 Perpetual Windows version 13.0.1.3 and the Subscription version 13.1.2. I use the  Subscription version 13.1.2 and it return the correct values  for the shape layer. I doe no have CS5 installed but do have CS2 installed  it return the incorrect values you posted. So I tried my purposed work around in CS2 it would work. The size was also wrong for then bottom right corner position was off like the top left.

JJMack