Scale Android drawables with a script
Here is a simple script to create lower-resolution Android drawables from higher-resolution ones.
For example, given a batch of -xhdpi images, it can generate -hdpi and -mdpi images.
With this script, it’s possible to export only highest-resolution artwork from authoring tools and then create the lower-resolution versions with a few batch commands.
Before, I would have to export all artwork versions one by one, adjusting the size, navigating to the right directory, double-checking to make sure I haven’t accidentally exported an -mdpi sized image into -hdpi, etc.
drawable_convert.py -d res/drawable-mdpi -d res/drawable-hdpi res/drawable-xhdpi-v14/select*.png
This will take select*.png from xhdpi and place lower-resolution versions into mdpi and hdpi folders.
Resize ratios are computed based on resource directory names.
The actual scaling is done by ImageMagick’s convert command.