Photoshop: Export Layers to Files (Fast PNG version)

Adobe Photoshop comes with a script called "Export Layers to Files" which saves each layer in the current document to a separate file. In a recent version of Photoshop you could find this under File -> Scripts.

I have taken the version of this script that comes with Photoshop CS3 and modified it to add two new features:

  1. Support for saving PNG files.

    It is strange that this was left out of the original script.

  2. Fast Mode (Don't remove hidden layers).

    There is a new "Fast Mode (Don't remove hidden layers)" checkbox which, when turned on, causes the script to export the layers in a much, much faster way.

    Normally the script duplicates the document for each layer and removes all other layers before saving the duplicated document. This means that only the desired layer is saved but it also makes the script really slow (it runs in O(n^2) time instead of O(n)). Turning on the Fast Mode causes the script to hide, but not erase, the unwanted layers. This means the resultant files may contain unwanted hidden layers, if saving to an image format which supports layers, but if you are ultimately just going to flatten and resave each file then this doesn't matter and saves you a huge amount of time.

Photoshop CS4 users: CS4 comes with an updated version of the original script which adds PNG support. I have not had a chance to look at it much yet but it looks better than my version of the CS3 script. So, if you have CS4, try the official script first. If I get time I'll see if it's worth adding a "fast mode" to the CS4 script or if such modifications are no longer needed.


I have only tested the script in Photoshop CS3 on Windows but it should work with the OS X version as well. I don't know if it will work in older versions of Photoshop.

Download (9k) (PGP sig) (Diff against original version)


To run the script, first extract the Export Layers To Files - (Fast PNG version).jsx file from the zip to somewhere sensible and then, in Photoshop, select File -> Scripts -> Browse... and then choose the .jsx file you just saved.

You can also copy the script to your scripts folder so that it appears in the Scripts menu directly the next time you start Photoshop. On Windows the folder is C:\Program Files\Adobe\Adobe Photoshop CS3\Presets\Scripts.

The original version of the script is not changed so you can go back to it if you find a problem in my modified version.


I hope Adobe don't mind me sharing my version of the script here. I figure these changes may be useful to other people but it's still their script and my modifications are quite minor. Here is the original copyright and credits for the script:

Copyright 2007. Adobe Systems, Incorporated. All rights reserved.
Written by Naoki Hada
ZStrings and auto layout by Tom Ruark


3rd June 2007

  • Initial modified version. Based on version of the script which came with Photoshop CS3.


I get a surprising (to me) amount of email about this script, much of which I haven't found the time to answer. I apologise for that. My email link is in the footer below but please don't feel bad if I don't reply for a long time.