Update: I’ve got a much improved version of the script that also exports artboards and adds a PDFs option. Get the improved version.
Hot on the heels of my Illustrator script to export artboards as PNG files, here’s one that exports Illustrator layers as PNG files.
To use the script, download Export-Layers-as-PNG.jsx and put in your Illustrator scripts folder (usually in Applications/Adobe Illustrator/Presets/Scripts/). Restart Illustrator, and run the script by going to “File > Scripts > Export Layers as PNG”.
- Files are named based on their layer name. It only exports layers where their name has been changed from the default “Layer 1″, “Layer 2″, etc.
- If you put a plus sign (+) in front of a layer name, that layer will always be visible. Useful for if you want to have a layer that always appears in the background of each exported image.
- If you put a minus sign (-) in front of a layer name, it will skip that layer.
- It stores its settings in a nonvisible, nonprinting layer named “nyt_png_info”
- It has an option for transparency, and lets you choose between PNG8 and PNG24.
You can try it out on the sample file layer-test.ai.
When you run this script on this file, it will export 2 PNGs: Play.png and Pause.png. The “+Button” and “+Gradient” layers will appear in the background of both exported files, and it will skip the “-Pause 2″ and “Layer 5″ layers.