On 5 Sep 2014, at 4:27 am, Dave <email@hidden> wrote:
I have a PSD that is 40,40 Pixels
I then have 4 Fill Rects at, X,Y with a Width, Height of 20,20
Rect1: X,Y: 0,0 Rect2: X,Y 20,0 Rect3: X,Y 0,20 Rect4: X,Y 20,20
Now when I read bounds in my Script I get everything offset by -1 or sometimes -2. From experimenting with other PSD this negative offset various.
Why is this?
Something in your code, I suspect.
It’s to do with the way in which layers “float” until they are flattened. So, a whole PSD have it’s original set somewhere in a infinite space, but the extent, width and height are constant.
Um, no, that's not so.
I made up a document as you describe and ran this:
tell application id "com.adobe.Photoshop" -- Adobe Photoshop CC 2014.app set theBounds to bounds of art layers of document 1 end tell log theBounds --> {{20.0, 20.0, 40.0, 40.0}, {0.0, 20.0, 20.0, 40.0}, {20.0, 0.0, 40.0, 20.0}, {0.0, 0.0, 20.0, 20.0}, {0.0, 0.0, 40.0, 40.0}} repeat with i from 1 to count of theBounds set item i of theBounds to my cocoafy(get item i of theBounds) end repeat return theBounds --> {{20.0, 20.0, 20.0, 20.0}, {0.0, 20.0, 20.0, 20.0}, {20.0, 0.0, 20.0, 20.0}, {0.0, 0.0, 20.0, 20.0}, {0.0, 0.0, 40.0, 40.0}}
on cocoafy({x1, y1, x2, y2}) return {x1, y1, x2 - x1, y2 - y1} end cocoafy
Unless PS is doing something different in _javascript_, that looks pretty straight-froward, with no sign of errant 1s.
|