Skip to main content
Known Participant
July 10, 2024
Answered

How to obtain the dimensions of the transparent area?

  • July 10, 2024
  • 1 reply
  • 328 views

Could you please tell me how to obtain the dimensions of the transparent area of the current layer? For example, I want to get the dimensions of the top, bottom, left, and right transparent areas separately. Specifically, I'm interested in obtaining the height of the top and bottom transparent areas, and the width of the left and right transparent areas.

 

This topic has been closed for replies.
Correct answer Stephen Marsh

@meadX – Ensuring that your calculations are set to pixels...

 

Use the app.activeDocument.activeLayer.bounds[0] for the left and app.activeDocument.activeLayer.bounds[1] for the top.

 

Use the app.activeDocument.width.value minus app.activeDocument.activeLayer.bounds[2] for the right.

 

Use the app.activeDocument.height.value minus app.activeDocument.activeLayer.bounds[3] for the bottom.

 

Related example code here:

 

https://gist.github.com/MarshySwamp/ef345ef3dec60a843465347ee6fcae2f

1 reply

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
July 10, 2024

@meadX – Ensuring that your calculations are set to pixels...

 

Use the app.activeDocument.activeLayer.bounds[0] for the left and app.activeDocument.activeLayer.bounds[1] for the top.

 

Use the app.activeDocument.width.value minus app.activeDocument.activeLayer.bounds[2] for the right.

 

Use the app.activeDocument.height.value minus app.activeDocument.activeLayer.bounds[3] for the bottom.

 

Related example code here:

 

https://gist.github.com/MarshySwamp/ef345ef3dec60a843465347ee6fcae2f

meadXAuthor
Known Participant
July 10, 2024

Thank you very much, I will try it first, thank you