Hi,
I’m using PS CS6.
On 5 Sep 2014, at 00:21, Shane Stanley < email@hidden> wrote: 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 not just my code, It shows this in standard scripts too. I’m not saying you can’t create a PSD that has everything 0,0 based it’s just you can also create one with negative X,Y.
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.
Well, you got lucky or you version of PS is different. I’m seeing -1’s, -2’s etc and one case where everything seemed to be based around 31!
Here is a dump of the bounds:
PhotoShop - Rect: [19 px,-1 px,41 px,21 px] PhotoShop - Rect: [19 px,-1 px,41 px,21 px] PhotoShop - Rect: [-1 px,19 px,21 px,41 px] PhotoShop - Rect: [19 px,19 px,41 px,41 px]
So, it’s definitely returning the rects shifted.
All the Best Dave
|