Exporting Photoshop Layers for Android
I’m working with a team on a rather large Android project that has a highly customized UI and therefore has a lot of artwork.
As is fairly typical for this type of project, the design is done by a third-party design house, and delivered as Photoshop PSD files.
For the developers on the project, it can be a bit time-consuming to manually copy layers from the PSD to new documents, resize them appropriately for all of the supported Android resolutions (ldpi, mdpi, hdpi, and xhdpi), and then export them to PNG files.
Not being a Photoshop expert, I was pleased to find that Photoshop is scriptable with several scripting languages, including JavaScript. Since JavaScript is the only one that’s supported on all platforms on which Photoshop runs, I figured I go with that.
Looking around the web, I found a number of scripts that claimed to at least export layers, if not resize them the way I want. Unfortunately, they just plain didn’t work. I’m guessing that they worked with previous versions of PS, and just weren’t compatible with CS6.
Finally, I found a very polished, working ‘Export for iOS’ script by Daniel Wood of runloop.com at http://pastebin.com/12dHWYm8
This script does exactly the steps that I was looking for, except that it does it for the various iOS asset sizes. If you are an iOS developer, and you don’t have something like this, go get it - it will save you tons of time.
So, I simply modified the iOS script to export image sizes appropriate for Android ‘drawable’ assets.
The script, along with a README containing instructions for installation and use are on my Github account at https://github.com/rfreedman/Export-Photoshop-Layer-For-Android