Skip to main content
Known Participant
July 10, 2024
解決済み

How to obtain the dimensions of the transparent area?

  • July 10, 2024
  • 返信数 1.
  • 328 ビュー

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.

 

このトピックへの返信は締め切られました。
解決に役立った回答 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

Stephen Marsh
Community Expert
Stephen MarshCommunity Expert解決!
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

meadX作成者
Known Participant
July 10, 2024

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