Get X and Y, and Width and Height of a layer

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

jaysmith123
Posts: 3
Joined: Fri Nov 02, 2018 2:33 am

Get X and Y, and Width and Height of a layer

Post by jaysmith123 »

From a script, how do I get the x and y coordinates of a specific layer? Also, how do I get the width and height of a specific layer?
Attachments
x and y and width and height.PNG
x and y and width and height.PNG (1.62 KiB) Viewed 6004 times
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: Get X and Y, and Width and Height of a layer

Post by Kukurykus »

Code: Select all

b = activeDocument.activeLayer.bounds
x = b[0], y = b[1], w = b[2] - b[0], h = b[3] - b[1]
alert(x + ' & ' + y + ' & ' + w + ' & ' + h)

I sent you PM if you have more questions...