Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer
    
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! –  Martín Escarrá Mar 25 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 Mar 25 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.

share|improve this answer
    
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. –  Martín Escarrá Mar 21 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. –  Alan Gilbertson Mar 21 at 19:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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