How to automate icon generation?
I have just discovered that Google Services puts some icons for high resolution devices (xhdpi and xxhdpi) into my projects resulting in my games having green android icon on some phones and tablest. What a nightmare! I had to update all of them with fixed icons. To make my life easier I have a script that generates a complete set of icons for Android and iOS from one 1024×1024 icon. It’s bash script for Linux, requires ImageMagick, but maybe someone will find a use for it.
How to use it? Change the “ic_launcher” for the name of your icon. Copy your icon as icon1024.png into the same folder as the script, create drawable-ldpi, drawable-hdpi, drawable-mdpi, drawable-xhdpi, drawable-xxhdpi there and run the script. It will fill the folders with icons and generate many useful icon sizes – the iOS icons have names ready to use in libGDX project.
Here is the script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #!/bin/bash #wersja 2.0 cp --remove-destination icon1024.png icon512.png mogrify -resize 512x512 -filter Lanczos icon512.png cp --remove-destination icon1024.png icon144.png mogrify -resize 144x -filter Lanczos icon144.png cp --remove-destination icon1024.png icon128.png mogrify -resize 128x -filter Lanczos icon128.png cp --remove-destination icon1024.png icon114.png mogrify -resize 114x -filter Lanczos icon114.png cp --remove-destination icon1024.png app_icon.png mogrify -resize 96x -filter Lanczos app_icon.png cp --remove-destination icon1024.png icon72.png mogrify -resize 72x -filter Lanczos icon72.png cp --remove-destination icon1024.png icon64.png mogrify -resize 64x -filter Lanczos icon64.png cp --remove-destination icon1024.png icon48.png mogrify -resize 48x -filter Lanczos icon48.png cp --remove-destination icon1024.png icon36.png mogrify -resize 36x -filter Lanczos icon36.png cp --remove-destination icon1024.png icon32.png mogrify -resize 32x -filter Lanczos icon32.png cp --remove-destination icon1024.png icon16.png mogrify -resize 16x -filter Lanczos icon16.png cp --remove-destination icon1024.png icon150.png mogrify -resize 150x -filter Lanczos icon150.png cp --remove-destination icon1024.png drawable-ldpi/ic_launcher.png mogrify -resize 36x -filter Lanczos drawable-ldpi/ic_launcher.png cp --remove-destination icon1024.png drawable-mdpi/ic_launcher.png mogrify -resize 48x -filter Lanczos drawable-mdpi/ic_launcher.png cp --remove-destination icon1024.png drawable-hdpi/ic_launcher.png mogrify -resize 72x -filter Lanczos drawable-hdpi/ic_launcher.png cp --remove-destination icon1024.png drawable-xhdpi/ic_launcher.png mogrify -resize 96x -filter Lanczos drawable-xhdpi/ic_launcher.png cp --remove-destination icon1024.png drawable-xxhdpi/ic_launcher.png mogrify -resize 144x -filter Lanczos drawable-xxhdpi/ic_launcher.png #ios cp --remove-destination icon512.png icon.png mogrify -resize 57x57 -filter Lanczos icon.png cp --remove-destination icon512.png icon@2x.png mogrify -resize 114x114 -filter Lanczos icon@2x.png cp --remove-destination icon512.png icon-72.png mogrify -resize 72x72 -filter Lanczos icon-72.png cp --remove-destination icon512.png icon-72@2x.png mogrify -resize 144x144 -filter Lanczos icon-72@2x.png |
#!/bin/bash #wersja 2.0 cp --remove-destination icon1024.png icon512.png mogrify -resize 512x512 -filter Lanczos icon512.png cp --remove-destination icon1024.png icon144.png mogrify -resize 144x -filter Lanczos icon144.png cp --remove-destination icon1024.png icon128.png mogrify -resize 128x -filter Lanczos icon128.png cp --remove-destination icon1024.png icon114.png mogrify -resize 114x -filter Lanczos icon114.png cp --remove-destination icon1024.png app_icon.png mogrify -resize 96x -filter Lanczos app_icon.png cp --remove-destination icon1024.png icon72.png mogrify -resize 72x -filter Lanczos icon72.png cp --remove-destination icon1024.png icon64.png mogrify -resize 64x -filter Lanczos icon64.png cp --remove-destination icon1024.png icon48.png mogrify -resize 48x -filter Lanczos icon48.png cp --remove-destination icon1024.png icon36.png mogrify -resize 36x -filter Lanczos icon36.png cp --remove-destination icon1024.png icon32.png mogrify -resize 32x -filter Lanczos icon32.png cp --remove-destination icon1024.png icon16.png mogrify -resize 16x -filter Lanczos icon16.png cp --remove-destination icon1024.png icon150.png mogrify -resize 150x -filter Lanczos icon150.png cp --remove-destination icon1024.png drawable-ldpi/ic_launcher.png mogrify -resize 36x -filter Lanczos drawable-ldpi/ic_launcher.png cp --remove-destination icon1024.png drawable-mdpi/ic_launcher.png mogrify -resize 48x -filter Lanczos drawable-mdpi/ic_launcher.png cp --remove-destination icon1024.png drawable-hdpi/ic_launcher.png mogrify -resize 72x -filter Lanczos drawable-hdpi/ic_launcher.png cp --remove-destination icon1024.png drawable-xhdpi/ic_launcher.png mogrify -resize 96x -filter Lanczos drawable-xhdpi/ic_launcher.png cp --remove-destination icon1024.png drawable-xxhdpi/ic_launcher.png mogrify -resize 144x -filter Lanczos drawable-xxhdpi/ic_launcher.png #ios cp --remove-destination icon512.png icon.png mogrify -resize 57x57 -filter Lanczos icon.png cp --remove-destination icon512.png icon@2x.png mogrify -resize 114x114 -filter Lanczos icon@2x.png cp --remove-destination icon512.png icon-72.png mogrify -resize 72x72 -filter Lanczos icon-72.png cp --remove-destination icon512.png icon-72@2x.png mogrify -resize 144x144 -filter Lanczos icon-72@2x.png
As you can see the script uses Lanczos for resizing which results in very high sharpness – not need to sharpen the images then.