dotnetco.de

Automatic creation of App Logos in different sizes

Both iOS and Android expect app logos in different sizes, starting from 29×29. Of course you could manually create all the icons, but it’s more convenient to do it with a script.

Xamarin.Forms Kickstarter is an excellent starting point for lots of different examples, e.g. Layouting, Web Access, Geolocation and lots more. There is also a separate section about App Icons. It contains a script which automatically creates lots of icons in different sizes.

#!/bin/bash

for width in 57 114 120 72 144 76 152 29 58 50 100 40 80
do
    size=${width}x${width}
    convert xamarin.png -resize $size\> -background transparent -gravity center -extent $size icon$size.png
done

So I copied the script from the website, added some additional dimensions (87, 180, 167, 55, 88, 172, 196 and 96)  and saved it to my local drive with filename “CreateAppIcons.sh” using a text editor like Visual Studio Code.

Then I opened the Terminal and switched to the directory where I placed both the script and a file called “xamarin.png” which contains my application icon template. I executed the script by using this command in the Terminal: “sh CreateAppIcons.sh”. But I got lots of error codes like this:

CreateAppIcons.sh: line 6: convert: command not found

Fortunately the author of the Kickstarter Page, Falko Schindler, was very helpful and said that this is caused by missing ImageMagick installation on my local macbook. The easiest way to install is using Homebrew. And that’s really simple. First, as stated on the Homebrew start page, execute one single line in Terminal. Afterwards, just install ImageMagick by executing this line in Terminal: “brew install imagemagick”.

And that’s it. Now the provided script runs fine and creates lots of different app icons.

So open your Xamarin Forms project and go to the iOS project. There you’ll find “Assets.xcassets”. Double-click, and then add your icons.

Leave a Comment