GIMP script for creating Android icons at once

by Goran Siric on Thursday, September 22, 2011 5:46 AM

If you are programming for Android then you know how hard is to create and manage all that icons for different screen sizes and resolutions.  I am using GIMP for creating all my icons and was trying to find script for creating all that icons at once.

The closest one I found is script for creating many PNG files with different sizes at once. That script helped me a lot in creating a this one.

How to install script for creating android icons

This script require GIMP 2.6 or higher.

Download script:  GIMP script for creating android icons

GitHub: ruleant/script-fu-save-android-icons

Unpack the file and copy script-fu-save-android-icon.scm file  to GIMP scripts folder. Its location depends where is GIMP installed and what version of GIMP you have. On my system this folder is: C:\Program Files\GIMP-2.0\share\gimp\2.0\scripts

How to use script

After you install script, you need to restart GIMP or select  Filters->Script-Fu-Refresh Scripts

Now you can run script using new menu item: Script-Fu -> Android -> Save Android Icons ...

You will get following dialog:


Under Android  icons type you can select what type of android icons you want to generate:

Launcher Icons
Menu Icons
Action Bar Icons
Status Bar Icons
Tab Icons
Dialog Icons
List View Icons
Custom Icon

Resolution of saved icons will depend  of what icon type you select. 

If you select Custom Icon then you must enter desired resolution for your mdpi icon as baseline icon dimension. Other icon will be scaled according to icon design guidelines:

  • ldpi icon will be 0.75 x width and height of  mdpi icon
  • hdpi will be 1.5 x width and height of mdpi icon
  • xhdpi icon will be 2.0 x width and height of  mdpi icon
  • etc..

With Save mode options you can select whether you want to save icons under same name but in different folders with standard android folder names  (drawable-ldpi,drawable-mdpi, drawable-hdpi, drawable-xhdpi) or you want to save all icons in same folder but with added resolution to the end of the file name. 

If you check Use android naming conventions then all icon names will be prefixed with common icon prefix for selected icon type.

Here you can find more about designing icons for Android: Android Icon Design Guidelines

Rest of the options are standard for saving PNG files and I think you will not have problem with them.

I hope you will find this script useful and feel free to leave comments and requests for improvement.

Update history

Updated 04.03.2015 (by Leonid S. Usov )
 - support for automatic creation of drawable subdirectories

Updated 13.12.2013 (by Dieter Adriaenssens
 - added support for XXHDPI and XXXHDPI screens

Updated 13.02.2012

Added support for

 -  action bar icons
 - icons with custom size
 - xhdpi screen icon

Download 

Script can be downloaded here:  GIMP script for creating android icons

or on GitHub: ruleant/script-fu-save-android-icons

Author
Goran Siric

Blog about programming

46 comment(s) so far...

Anonymous 9/24/2011

This is a great script. Please include the instructions on this page in the zip file. I have made a pdf file of them. If you are interested, I can email the file to you.

 
Goran Siric 9/24/2011

Sure, you can send me pdf with instructions at goran.siric@izvornikod.com

 
Anonymous 9/30/2011

Your script is very good and was exactly what I look for !<br /><br />I test it with Gimp 2.2 and it is not working. It's ok in 2.6.<br />You should remove 2.0 in your blog as it is confusing, or better say that it need 2.6 or upper.<br /><br />I have another little pb, my android eclipse version creates res directory with drawable-xxxx and not xxxx directly. I think it's a new way to do from google.<br /><br />Great script anyway.<br /><br />I talk (in french on my blog): <a href="http://histoires-android.blogspot.com/2011/09/creer-des-icones-android-en-un-seul.html" rel="nofollow">histoires-android.blogspot.com/2011/09/creer-des-icones-android-en-un-seul.html</a><br /><br />Bue,<br />Vicnet

 
Goran Siric 10/3/2011

Thank you for your feedback. I updated script to save icons in drawable-xxxx folders.

 
Anonymous 10/3/2011

me too ;-)

 
Goran Siric 10/12/2011

Today I noticed that in some cases sizes of generated icon are not correct. After some research I found the problem. If image have one or more layers with size different then image, then generated icons have size which corespond to layer size and not the image size. To fix that script is updated with command to set size of all layers to image size. <br /><br />Also I noticed that sizes for generating tab icons are wrong. That is fixed too.

 
Anonymous 10/21/2011

Great scrip man. I tried it with menu icons and got a great result in a second. <br />But when I applied it to status bar icons it didn't add the layer effects recommended by Android status bar icon design guidelines, or was it me using it in a wrong way? <br />Finally, I see that your script has great potential :)

 
Goran Siric 10/21/2011

Script currently use your image only as a template to create android icons with preffered dimensions. It does not add any effect or something like that. You need to create image with transparency and all efects you want and then use this script to save icons with different sizes. <br /><br />I was thinking about adding some functionality to apply some style and colors to image before creating icons for status bar icons and tab icons, but in most cases you will not get desired result. I think that it is better to create icons on your own, with styles and effects you want.<br />

 
Anonymous 1/26/2012

Thank you SO MUCH!!! <br />I found the script you mentioned first but didn't have the skills to adjust it so it fitted my needs. You did it for me: THANKS!<br /><br />Don't know if it is too much to ask. But what if you add a custom "Android Icon Type" that just scales the other pictures (mdpi and ldpi) according to the hdpi. So say I have an image that I want to have a size of 100x80px in the hdpi folder -> then it scale it down to 66% (48/72) of that and put it in the mdpi -> then it scales that mdpi image down to 75% (36/48) and put it in the ldpi. <br />My experience tells me that it is better to scale a this step-wise way than to scale the biggest down to the smallest. <br /><br />(My next goal is to find an easy plugin in eclipse that allows me to add all the images to each of the drawable folders with much more ease than the drag and dropping- yes I'm lazy programmer)

 
Goran Siric 1/26/2012

Hi Norfeldt,<br /><br />I am little busy this days, but will try to add that functionality for custom icon type next week. <br />According to android guidelines mdpi icon is baseline, and then ldpi,hdpi and xhdpi icons are scaled based on mdp. I will also add xhdpi icon type. For your next goal – did you know that you can save icons directly in your working project folder, and eclipse will automatically add them to the project ? <br />

 
Anonymous 2/2/2012

Hello.<br />Nice work.<br />But, the xhdpi icones are not created.<br />"96x96 for extra high-density"<br /><a href="http://developer.android.com/guide/practices/screens_support.html" rel="nofollow">developer.android.com/guide/practices/screens_support.html</a><br />Thanks.

 
Goran Siric 2/13/2012

Hello all, <br />script is updated with some new features. <br /><br />Added support for:<br /> - action bar icons<br /> - icons with custom size<br /> - xhdpi screen icon<br /><br />I hope that there is no bugs introduced. <br /><br />Enjoy

 
Anonymous 2/13/2012

Thank you so much! Have donated some money to you so you can buy yourself a good beer. <br />You deserve it!

 
Goran Siric 2/16/2012

Thank you for supporting me :)

 
Anonymous 2/29/2012

sorry for writing in English I am French but I vien to find thanks to google finally information on the subject that I currently work thank you for sharing good information thanks to you I will advance 'll see you soon I'll follow you to the next and I recommend reading your blog friendly

 
Anonymous 9/7/2012

Great script! I love it.

 
Anonymous 9/13/2012

I'm running OSX Mountain Lion and Gimp 2.8. I followed your instructions above to install the plugin, but the filter is not showing up. Are there any extra steps I need to perform to enable the filter? I tried restarting GIMP and selecting to refresh scripts, but neither seemed to work. Any help would be appreciated.

 
Goran Siric 9/17/2012

Hi Brian,please try to follow this tutorial for adding GIMP scripts on Mac:<br /><br /><a href="http://www.gimptalk.com/index.php?/topic/36105-adding-scripts-to-gimp-using-a-mac-easy-10-step-tutorial/" rel="nofollow">www.gimptalk.com/index.php?/topic/36105-adding-scripts-to-gimp-using-a-mac-easy-10-step-tutorial/</a><br /><br />Note that in step four you don't need to download script from the link in article, just use already downloaded script for creating Androind icons. <br /><br />Or you can try following:<br />The scripts are kept inside the application resource package:<br />Go to the Gimp application and control-click on it;<br />select 'Show Package Contents';<br />go to Contents>Resources>share>gimp>2.0>scripts;<br />and insert the wanted script.<br />If Gimp is running, activate the script by going to Filters in the menu and select Script-Fu>Refresh Scripts.

 
Anonymous 12/19/2012

Thanks!!!

 
Anonymous 1/31/2013

Just wanted to say that this script was a great help to me! Nice work. :-)

 
Anonymous 3/8/2013

Hello,<br /><br />very nice script, thank you for it!!!<br /><br />Want to ask if you can add support for xxhdpdi icons with 144x144 pixels and 96 dpi?<br /><br />Peter

 
Anonymous 3/8/2013

I suggest to name the menu "Android -> Save icons..." so it saves one click each time.<br /><br />Peter

 
Anonymous 4/26/2013

It would be worthwhile to use DIR-SEPARATOR instead of "/" so this will work on (cough) Windows.

 
Anonymous 11/14/2013

Thanks!

 
Anonymous 12/13/2013

I add support for the xxhdpi and xxxhdpi screen sizes to the script.<br />Do you have a public repo of this script where I can create a pull/merge request with the changes?

 
Anonymous 12/16/2013

I created a repo in github [0] with my changes (xxhdpi and xxxhdpi support) added to your script, feel free to clone it : <a href="https://github.com/ruleant/script-fu-save-android-icons" rel="nofollow">github.com/ruleant/script-fu-save-android-icons</a><br />I'm happy to transfer this repo to you if you have a github account.<br /><br />

 
Goran Siric 1/28/2014

Hi Dieter,thanks for update.

 
Anonymous 8/18/2014

Thanks for this script, but it doesn't works on windows as it use slash instead of antislash for paths

 
Anonymous 8/26/2014

It didn't work for me. I always get this error message<br /><br />Error while executing script-fu-save-android-icons:<br /><br />Error: ( : 53244862) Procedure execution of file-png-save2 failed: Could not open 'C:\Users\dgp\Desktop/drawable-ldpi/fb.png' for writing: No such file or directory

 
Anonymous 9/16/2014

Please help <br /><br />Error while executing script-fu-save-android-icons:<br /><br />Error: ( : 32559) Procedure execution of file-png-save2 failed: Could not open path_to_folder /drawable-ldpi/icon.png' for writing: No such file or directory

 
Anonymous 9/26/2014

Same here^

 
Goran Siric 9/29/2014

This is not problem with slahs/backslash.Make sure you have all drawable folders:<br />drawable-ldpi<br />drawable-mdpi<br />drawable-hdpi<br />drawable-xhdpi<br />drawable-xxhdpi<br />drawable-xxxhdpi<br />created in "Root folder" before saving icons.

 
Anonymous 1/9/2015

Hello,<br /><br />great job, saved me a bunch of manual labor!<br />Would it be possible to add an option to create the ouya_icon.png and the Android TV banner.png?

 
Anonymous 1/9/2015

Would it also be possible to leave out the _ in the namepreffix if the name itself is empty? Thanks.

 
Goran Siric 1/14/2015

Dear Wildy,<br />ouya_icon and android TV banner are not icons with equeal hight and width, so it will be hard to decide which part of the image to use for creating this icons. Maybe you can use custom MDPi widht/height for this purpose?<br /><br />Leaving out _ in the nameprefix when the name itself is empty can be done.

 
Anonymous 1/27/2015

ouya_icon and banner both are 1.777777777777778 aspect ratio. I usually start with a 720p or 1080p bitmap maybe it would be possible to check for the correct aspect ratio before offering that option? Or before converting the bitmaps?<br />Thanks for the other fix though, it'll also save me a bit of manual renaming.

 
Goran Siric 1/28/2015

Dear Wildy,ouya and banner icons are completly different icons then standard android icons, and many of standard options don't apply to them, so I decided to write new script for you:<br /><br /><a href="http://www.izvornikod.com/download/script-fu-save-ouya-and-tv-banner-icons.rar" rel="nofollow">www.izvornikod.com/download/script-fu-save-ouya-and-tv-banner-icons.rar</a><br /><br />Installation procedure is the same as for the first script.

 
Anonymous 1/28/2015

Wow, thanks! I tried to hack your original script to add it in there but I don't know anything about script-fu and it ended up horribly. <br />Just a couple of notes: the ouya name and location matters so I changed it to:<br /><br /> (set! newName (string-append folder "/drawable-xhdpi/ouya_icon.png"))<br /> (set! rawName "ouya_icon.png")<br />and this for banner (the name here is just a personal preference)<br /> (set! newName (string-append folder "/drawable-xhdpi/banner.png"))<br /> (set! rawName "banner.png")<br />Thanks again!

 
Anonymous 2/20/2015

There is a new way to register Android app icon... you can now set them in mipmap folder instead of drawable folder.<br />Thank's for this top plugin.

 
Anonymous 2/28/2015

Hi,<br /><br />good script, thanks for that.<br />I have found it midway writing my own. I just thought to myself "hey, you seem to be doing something others might have done better", which was the case. Again. <br />However, I would like to contribute. <br /><br />I have found a way to create directories from within a script-fu, although this wasn't for some reason described on gimp forums. I have patched your script and it works nice. Please feel free to add this line just before file-png-save2:<br /><br />(python-fu-eval 1 (string-append <br /> "import os;\ntry:\n\tos.makedirs(os.path.dirname('" <br /> newName <br /> "'))\nexcept OSError as exception:\n\tif exception.errno != errno.EEXIST:\n\t\traise"))<br />

 
Anonymous 2/28/2015

Also,<br /><br />would you consider merging with this opensource script to have the two great extensions in one place?<br /><br /><a href="https://github.com/m2orris/GIMP-scripts" rel="nofollow">github.com/m2orris/GIMP-scripts</a><br />

 
Anonymous 3/1/2015

Sorry for spamming J<br /><br />skipped it at first, but then found in one of the comments above a link to a github repository with the code. Have contributed with this pull request. Please see it for a small bugfix to my original post above (missing python import will crash the code if the directories exist). Plus the windows compatibility issue by using a platform dependent DIR-SEPARATOR.<br /><br /><a href="https://github.com/ruleant/script-fu-save-android-icons/pull/1" rel="nofollow">github.com/ruleant/script-fu-save-android-icons/pull/1</a><br /><br />Cheers!

 
Goran Siric 3/1/2015

Hey Leonidthanks for your code for creating folders.This is always problem when someone don't read documentation. <br />I will update script on this page too in next few days.

 
Anonymous 3/3/2015

I'm using 2.8.14 and copied script to folder that described in pdf document. Save Android Icons menu item appeared in right place but it disabled. Any workaround?

 
Goran Siric 3/4/2015

is it possible that you don't have any active image?<br />You must have working image to have items enabled.

 
Anonymous 12/1/2015

Hi<br />Script is working on Linux (Ubuntu/Mint), copy script to /usr/share/gimp/2.0/scripts<br />refresh FIlters->Script-Fu->Refresh script <br />after new manu is shown at top (Script-Fu) and you should have Android under



  Hi folks! I am proud to present: 
Bubble Zoo Escape, my first Android game built using AndEngine 
If you have a time, please download and give feedback!

If you found this useful,
you can buy me a coffe :)

By me a coffe through PayPal :)


Featured articles

AndEngine - Textures tips and tricks

What you should know abot textures before get started programming your first game.

GIMP script for creating Android icons at once

Script for creating Android icons for different screen resolutions at once. Icons can be saved using standard Android icons naming conventions and saved in appropriate folders.

Creating Android button with image and text using relative layout

Source code with examples how to use relative layout to create nice buttons with text and images in Android

Android application and the Internet

Tutorial about connecting to the web pages on the Internet from Android application, using both POST and GET web requests.

Copyright 2011 by Goran Siric