Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for professional graphic designers and non-designers trying to do their own graphic design. It's 100% free, no registration required.

I am a web dev and competent in Fireworks but not so much in Photoshop.

I have just received a layered PSD file to turn into a web page. Can anyone tell me the easiest way to export all layers to individual png files?

There are lots of layers and doing this manually seems wrong.

I have seen this but it does seem there should be native functionality for this in PS.

I have access to Photoshop CS4. Any pointers appreciated.

share|improve this question
    
Is there any way to avoid having the .pngs turned into Index mode? I need them RGB. I could probably just create a droplet for it, but didn't know if there were an easier way... Thanks for the tip though, this is great! –  user2995 Nov 25 '11 at 23:17
add comment

migrated from photo.stackexchange.com May 10 '11 at 18:18

This question came from our site for professional, enthusiast and amateur photographers.

3 Answers

up vote 56 down vote accepted

Method 1: The Built-In Script from Adobe

File >> Scripts >> Export layers to files...

enter image description here

Here are some related questions...

Exporting individual layers in Photoshop, keeping their sizes

Export Layers to Files exports only 4 png files from 100 layers


Method 2: Custom Script

I spent some time and wrote my own script file to automate this process. This process is much faster than the built-in script mentioned above.

Get the script now on Github!

Special thanks to escalation746 for doing some clean-up work on my script (it was really bad).

Performance

I ran this script on a 100 layer, 450MB file in under 60 seconds. Running the built-in script on the same file takes me about 30 minutes.

When testing with nest layer groups, I found that my script runs in about 90 seconds whereas the built-in script takes about 27 minutes (and actually exports it wrong).

Please note that these results will vary depending on the complexities of the files as well as the hardware on your computer. It also wouldn't surprise me if it varied between versions of Photoshop.

Please let me know if you run into any issues with the script. My contact info may be found here.

Instructions for use: File -> Scripts -> Browse... (then find the script).

Here are screenshots to help if you need additional help.

IMPORTANT: The images will automatically be saved in whatever directory your multi-layer file is contained in! Feel free to make any adjustments to the script as needed.

Disclaimer: Please use script at your own risk. I have not tested it thoroughly enough to guarantee that it is in fact bulletproof.

share|improve this answer
    
Thank you for your answer and this does seem to work on simpler files...but... the more experience I have of this the more laggy it seems. The PSD files I get arent massive maybe 100 layers tops but running the above technique seems to take hours (literally) and hangs and errors quite a lot. My PC is half decent but this process seems to run it into the ground - am now on CS5 but this has become unworkable any more suggetions please? –  user256888 Aug 29 '12 at 22:03
    
I wrote my own script that does this process much faster. Let me know how it goes! Cheers. –  Johannes Sep 1 '12 at 3:18
    
+1 For coming back and providing the script - it sounds great. One thing when I run it on a psd with multiple layers it always throws an alert saying ".....this document contains 1 layer continue?" but it actually contains many more layers? I think I might be missing something as mentioned I'm not a PS expert! Thanks –  user256888 Sep 4 '12 at 10:41
    
That's weird. What version of Photoshop are you using? Could you give me more information on the types of layers they are (regular raster layers, text, masks, etc.)? I can't seem to replicate your problem. –  Johannes Sep 5 '12 at 2:11
    
It looks like your script does not handle layer sets, so it will only output the layers that are direct children of the document. –  nEx.Software Nov 16 '12 at 15:52
show 6 more comments

CREDIT GOES TO JOHANNES FOR CONTRIBUTING THE FILE. THANK YOU SO MUCH!

I have added a function that helped me go through my 2448 layer file in about 3 hours.

Here is the link to the modified file Download Here

share|improve this answer
    
Glad to have helped. I assume the change is that you hide all other layers? –  Johannes Sep 2 '12 at 4:48
    
Yes cause with a big file like that it would take forever to manually hide all layers. For some reason when i tried your original script it would save the files with all the layers visible which would have a output png with all layers visible. Which was weird. So i added the function to hide all others layers except current one then save then hide it. –  Mike June Bug Captain Sep 2 '12 at 8:10
    
Oh my! I forgot to take into account transparency, you're right. I just have it turn off the top-most layer. I'm actually building a slightly more customizable script, and I'll add your transparency thing in. –  Johannes Sep 2 '12 at 9:21
    
+1 For broadening on the answer - thanks. –  user256888 Sep 4 '12 at 10:39
add comment

I have updated Johannes' solution of a year ago with many improvements. Significantly:

  • Layer groups are now properly handled so that all layers get written.
  • File names are auto-incremented to prevent collisions (this happens when more than one layer has the same name).
  • Performance is increased. The script can save 500 simple layers in a few minutes.

Besides this, the code has been cleaned up. For example, global variables have been integrated into a single array.

Note that the initial popup message will only tell you the number of top level layers. This is to avoid performance degradation. I can't really imagine a case where you don't know anything about the file you are dealing with, so this should not be much of a compromise.

Grab the script here. Thanks to the previous author for leading the way.

share|improve this answer
add comment

protected by Community Nov 1 '12 at 5:29

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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