• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Find out the size and position of an object in a layer

New Here ,
May 21, 2021 May 21, 2021

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.

Views

726

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 22, 2021 May 22, 2021
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) {}

Votes

Translate

Translate
Adobe
Community Expert ,
May 22, 2021 May 22, 2021

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) {}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

How to use these? Just in case. I want the position from the top left.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

LATEST

 

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:

 

alert.png

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines