Copy link to clipboard
Copied
Hello. How to convert a PSD file to HTML/CSS? Or to any other file, where the size and position of the object in the layer will be indicated.
Or how do I find out the position of an object in a layer?
I got tired of finding the position and size of the object every time.
try {
var bounds = activeDocument.activeLayer.bounds;
alert ("\nx: "+bounds[0]+"\ny: "+bounds[1]+"\nwidth: "+(bounds[2]-bounds[0])+"\nheight: "+(bounds[3]-bounds[1]))
}
catch (e) {}
Copy link to clipboard
Copied
try {
var bounds = activeDocument.activeLayer.bounds;
alert ("\nx: "+bounds[0]+"\ny: "+bounds[1]+"\nwidth: "+(bounds[2]-bounds[0])+"\nheight: "+(bounds[3]-bounds[1]))
}
catch (e) {}
Copy link to clipboard
Copied
How to use these? Just in case. I want the position from the top left.
Copy link to clipboard
Copied
You first need to save the JavaScript and install or run it ad-hoc. Everything you should need to know is detailed here:
Downloading and Installing Adobe Scripts
When run, you will be presented with a prompt informing you of the co-ordinates starting from the upper left.
I had a 300x300px canvas, with targeted layer content in the upper left corner, this is the result of running the script: