• Automatic Android resource generation with Photoshop scripts

    by Alexander Gazarov in Android development


    As it is known, when developing for Android, you have to keep in mind that you should create resources for all the pixel densities. Originally there were only three of them: ldpi, mdpi, and hdpi. However, the progress waits for no one: pixel densities have been growing to crazy numbers, and Google has been slyly adding the letter "x" and got to xxxhdpi by now, which means that now there are six major screen configurations. But even that's not all, because some resources have several different states. Buttons on the action panel have two states, and that would be decent enough, but common buttons have much more of them.

    There are several ways out of this situation: nag your artist, let multiple density support slide and hope that the system is going to somehow handle resource scaling on its own, or you could also do what programmers like to do the most: automation. There are various tools which can help with this. The most advanced one is probably Android Asset Studio. But the icons are, of course, drawn only for the common cases, and if you need to draw something custom, with unique styles, it is a poor helper. And that's where we have something to rescue us: scripting support in a fairly well-known instrument, Adobe Photoshop. In order to simplify the whole process, your humble servant has written several scripts for myself just for the cases like this, and now I'm sharing them with the readers. This article is where I'm going to describe how they work and how they are used. All the sources can be grabbed on BitBucket, and here I will show major points of interest and also I will shed some light on various tricks of working with Photoshop scripts which could be not obvious for beginners.