Matthew B Matthew B - 3 years ago 124
AppleScript Question

Get Height of layer or selection in Photoshop with AppleScript

I am having a lot of trouble trying to get the height of a layer or a selection of a layer in Photoshop using AppleScript. My end goal is to get the height of lets say Layer A and then the height of Layer B and find the difference. It is part of a much bigger script but nothing I do or search seems to yield any answers.

Thanks for your help in advance!

Answer Source
tell application "Adobe Photoshop CC 2015.5"  -- replace with the version of Photoshop you have
    activate
    set theDimensions to bounds of current layer of document 1
    set theWidth to item 3 of theDimensions
    set theHeight to item 4 of theDimensions
    set theDimensions to theWidth & theHeight
end tell

I use inches as the unit of measurement in my Photoshop documents so this script returns the values as inches in the results. I assume if you use pixels or other… This script will return the appropriate values

If you do not need the width values in this script, just comment them out

Here is the version for the height only

tell application "Adobe Photoshop CC 2015.5"  -- replace with the version of Photoshop you have
    activate
    set theDimensions to bounds of current layer of document 1
    --set theWidth to item 3 of theDimensions
    set theHeight to item 4 of theDimensions
    --set theDimensions to theWidth & theHeight
end tell
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download