Bounding Box for Text layers issue

Bounding Box Dimensions

Objectives

  • To get the exact bounds values for text layers from the api
  • But as we couldn’t find the exact values shown in the Transform section of PS from batchplay api we formed our own calculation with the available values.

Approaches

  • Extracted property called textKey using batchplay command, where we had a bounds key which contains top, bottom, left and right.
  • And also had transform key which contains xx, xy, yx, yy so the equation we formed to the actual width and height of the text layers

Width = (right - left) * xx
Height = (bottom - top) * yy

Problems

  • So the Width and Height is fine now. But the x and y coordinates we are using the bounds from the layer itself. But it had slight variations in Y values for around 10 - 20px.
  • The values from textKey are not around the ones showing in the app.
  • So if we can get the exact x and y coordinates or which ones should we rely on for the precise values.

Any insights or suggestions would be greatly appreciated!

Is layer.bounds not accurate for text layers?
https://developer.adobe.com/photoshop/uxp/2021/ps_reference/classes/layer/

No its not, the value which is shown in the properties tab in PS UI is different from what we get via UXP api and Layer. Bounds. Sometimes its almost close, but we don’t get the same exact values for w, h , top , left correct altogether. Because of that there are lots issues asscoiated with that. Any pointers related to this ?

Oh, that is interesting. Can you give me an example of a situation where the values are different?