I'm trying to do some basic stuff. I have a psd file with plenty of layers. Just one of the is the background and all the rest are objects above the background (each one separated in one different layer).

I want to export this to files. So I used the 'Export layers to files' option, which worked just fine and trimmed the layers to its boundaries as I wanted. The only problem is that now I have to go layer by layer to check its object absolute position in the background and make a list (I'm using this for programming purposes).

What I'd like to have, which shouldn't be so difficult, is the coordinates of the trimmed layer in the whole background. Is there a way to obtain this programmatically?

Thanks in advance, Martín

2 Answers 2


I only have the cs4 photoshop scripting reference on hand (freely available from adobe).

The object name for a layer is ArtLayer and there is a property called Bounds which is:

Read-only. An array of coordinates that describes the bounding rectangle of the ArtLayer.

This might allow you to query the layers and extract the data you need. The trick would be to align this data with the files but if they are named the same as the layers, it would be trivial.

google terms: photoshop_cs4_vbscript_ref.pdf photoshop_cs4_scripting_guide.pdf photoshop_cs4_javascript_ref.pdf

There is probably an Actionscript reference as well. Scripts can be run from within the application, but you can write OS-hosted scripts and still access the objects.

  • Thanks! I've modified an existing script (The one that exports layers to files) to print the bounds of each layer and it was fine. The only thing is that these bounds are given in centimeters in the structure and I would like pixels, so I did another script to parse these results into pixels. But I managed to do it. Thanks again!
    – mescarra
    Commented Mar 25, 2014 at 13:54
  • I think that if you change a measurement/ruler property for the document to pixels, it will handle the conversion for you. (in the script: query it, store it, change it, revert it)
    – horatio
    Commented Mar 25, 2014 at 14:32

This is a version-dependent answer, because you'll need to be on CS6 or later.

  • Select a layer

  • Layer > Copy CSS

  • Paste to your text editor of choice

Repeat this process for each layer. If you've enough layers, or this is something you're likely to want to do regularly, you can automate this with an action.

This second Method requires Ps CC:

In Ps CC, the Generate function in the File menu, especially when it's used in conjunction with the Adobe Layer Namer panel, automates the export of images and can save time because the images are updated instantly as things change in the PSD.

Ps can also create an Edge Reflow project automatically via File > Generate > Edge Reflow Project. As of this writing, the process remains quite buggy, but once Reflow gets out of "Preview" stage, there may be a very fast workflow available.

  • I'm currently working on CS6 extended (version 13.0) and I don't seem to find the 'Copy CSS' option within the Layer menu.
    – mescarra
    Commented Mar 21, 2014 at 16:05
  • Hmm... I've been beta testing Ps for so long that I occasionally get confused about what feature came in when, particularly since the launch of Creative Cloud. The Copy CSS feature is specific to the CC version of Ps CS6, which I run on my production machines. Commented Mar 21, 2014 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.