Script to produce iPhone app icons at different sizes

The tools for writing iPhone software are really easy to use, and allow you to concentrate on the coding rather than on obscure configuration problems. But one area of iOS development that I found a little tedious whilst writing my Solar Balls game was producing Apple’s mandatory and optional icons, which need to be in a variety of sizes.

The application icons need to be generated at different sizes for the old screen resolutions, retina display resolution and for iPhone/iPad screen types. There are also other sizes you can produce for Spotlight and Settings.

The different icon sizes are described on Apple’s developer website here and here.

If you work for a big company and have access to an art department they may well manually produce optimised version of each icon. I don’t have an art department and don’t have time (or the interest!) to optimise each icon so I just wrote a very simple script to do the resizing for me.

It takes a source image and then resizes it into 8 different icons. It gives them names that fit in with Apple’s old recommended icon naming conventions.

solar balls lite icons

Icon list

57x57 Icon.png
114x114 Icon@2x.png
72x72 Icon-72.png
144x144 Icon-ipad@2x.png
29x29 Icon-Small.png
58x58 Icon-Small@2x.png
50x50 Icon-Small-50.png
100x100 Icon-Small-100.png

Usage

generateIcons.bat sourceicon [tag]
e.g. 
generateIcons.bat iTunesArtwork
generateIcons.bat iTunesArtwork Lite

Or you can just drag the source image over the batch file.

If the first example the icons will be generated from your iTunesArtwork image with the names previously listed.

In the second example a tag is inserted into the name. So if the tag is ‘Lite’ then instead of Icon.png, you get IconLite.png. This can be very useful if you are using one XCode project to produce both a full and a lite version of your app.

You’ll need to have ImageMagick installed and on your path for this to work – ‘convert’ is a binary from ImageMagick.

This is a Windows batch file but you could easily convert it to a Mac OS shell script. I just happened to be using Windows at the time I was doing the icons for Solar Balls.

iPhone icon resizing script


goto :skip_functions

:makeAppIcons
	:: iPhone icon generator
	:: Details at https://www.reviewmylife.co.uk/blog/2012/05/29/script-to-produce-iphone-app-icons-at-different-sizes/
	set filename=%1
	set tag=%2

	:: icon sizes from 
	:: http://developer.apple.com/library/ios/#qa/qa1686/_index.html
	:: http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/IconsImages/IconsImages.html#//apple_ref/doc/uid/TP40006556-CH14-SW1
	
	:: App icons
	convert %filename% -thumbnail 57x57 Icon%tag%.png
	convert %filename% -thumbnail 114x114 Icon%tag%@2x.png
	convert %filename% -thumbnail 72x72 Icon%tag%-72.png
	convert %filename% -thumbnail 144x144 Icon%tag%-ipad@2x.png
	
	:: Spotlight search result icons
	convert %filename% -thumbnail 29x29 Icon%tag%-Small.png
	convert %filename% -thumbnail 58x58 Icon%tag%-Small@2x.png
	convert %filename% -thumbnail 50x50 Icon%tag%-Small-50.png
	convert %filename% -thumbnail 100x100 Icon%tag%-Small-100.png
	
goto :EOF

:skip_functions

call :makeAppIcons %1 %2

:end

It should be very obvious how to generate any additional sizes that you might need. And you could of course use a very similar script for resizing other app images that you might need for the standard/retina/iPhone/iPad screen resolutions.

Leave a Reply

Your email address will not be published. Required fields are marked *

Do NOT fill this !