Photoshop: Script - How to get real layer.bounds dimensions including transparent pixels around?

  • 1
  • Question
  • Updated 2 years ago
  • (Edited)
PS - script - How to get real layer.bounds dimensions including transparent pixels araound?
I wan't move left corner of my layer to point 0, 0 of my document.
function moveLayerTo(fLayer,fX,fY) {

var Position = fLayer.bounds;
Position[0] = fX - Position[0];
Position[1] = fY - Position[1];

fLayer.translate(-Position[0],-Position[1]);
}

Photo of Jaroslav Bereza

Jaroslav Bereza

  • 805 Posts
  • 186 Reply Likes
  • confused

Posted 3 years ago

  • 1
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 818 Reply Likes
Transparent pixels on the outside don't count toward the layer boundary. Only non-transparent pixels contribute to the layer bounds.  So there is no way to get the information that you are looking for.
Photo of Jaroslav Bereza

Jaroslav Bereza

  • 804 Posts
  • 186 Reply Likes
hmm ok so... I will do next workaround in my workaround.

Or is there better way how to place layer on my position including transparent pixels?
Photo of Jaroslav Bereza

Jaroslav Bereza

  • 805 Posts
  • 186 Reply Likes
My solution is open Smart Object and measure document dimension inside and calculate how much is SO smaller/bigger in percent values.

Now I am working on script which will read PSD-file bytes.
Photo of Jaroslav Bereza

Jaroslav Bereza

  • 805 Posts
  • 186 Reply Likes
Solved in PS CC2017

Values are accessible with AM code. (Smart objects)