📜 ⬆️ ⬇️

Another script for generating icons for Android

Hi, Habr!

Small introduction


For a long time I have been working as a mobile application tester. Mostly, android applications (although there were both WinCE and iOS). Predominantly with my hands (although I tried to automate with monkeyrunner and uiautomator). Recently, more and more time has to be devoted to the design of interfaces, management issues, releases and other matters. In short, the tasks have to be solved, though usually simple, but rather diverse. I would like to tell about one of them.

What's the matter


Recently, a colleague and I in the Rumsunrise team experimented with support for android 5 and material design in our applications. In the process of preparing the project, we encountered an unexpected minor problem from the field of design.

The fact is that we renamed some icons from the standard icon pack to make it more convenient to use them in our projects. And with the release of the new Android and, accordingly, the new icon pack from Google, we needed to enclose the project and new icons.
')
What does this mean for us? Select new icons from material-design-icons for each dpi value and decompose them into the necessary directories. Further, in each directory to rename the icons in accordance with how it is accepted in the project. When there are two or five icons, there are no problems - this is done quickly and painlessly. But if, let’s say, there are 25 icons, then renaming even a part of them manually is long and uninteresting. And if you consider that in addition to the icons, there is another graphic (which, by the way, may change from time to time), the situation was quite sad.

And then we thought that it would be nice to do this work once for icons and graphics that have the highest resolution (now it is xxxhdpi), and make the rest of the work a script.

What is Google? A quick study of the issue led us to a certain number of scripts for Gimp and Photoshop and tools like an icon generator from the Android Asset Studio set . We are, frankly, not very happy. At least, because it was necessary to do immediately and a lot. In order not to resize, rename and not lay out all the icons and graphics manually, we wrote a simple (one might even say primitive) script in python, which now does it for us.

So, I have a set of xxxhdpi graphics, ready for use in the android-project. From it I need to get the icons of all necessary sizes and put them in the appropriate directories.

All I need to do now is:

Add the necessary xxxhdpi icons to some directory and do:

$ iconic2.py /path/to/xxxhdpi/icons 

What exactly does the script do:

After that, it remains only to pick up ready-made kits and put them into the project.

To change the size of the icons, we use PIL or Pillow (for ubuntu x64). So what should be done beforehand:
 $ sudo apt install pillow 

Or what you usually do to install packages in your distribution.

The script itself is available in the mercurial repository on Bitbucket . I want to say that the script does not claim to be a universal tool or a sample of good code. We know that there are still many places in it that can be done better. But now he works and saves us time. I hope he will save him and you.

Source: https://habr.com/ru/post/243059/


All Articles