Home > android, tools > Scale Android drawables with a script

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.

Script usage:

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.

https://gist.github.com/2771791

Advertisements
Categories: android, tools
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s