Automated build of Icon/Loading Files

I wrote a post a while back about using Image magick and a bash script to quickly to create the various size app icon images you need for your mobile app.  This is just an updated version of that post.

Automated build of Icon/Loading Files  (originally posted 3/24/2012)

Because of the number of different icons needed for mobile apps I needed a quick method to input a master image and then convert the multiple images for Android and iOS.  Ideally I would like something that runs from the command line so I don’t have to open any software apps that will bog down my system.  As much as I looked, I could not find a quick, cost effective (read that as free), software independent, OS independent, method for resizing icon/loading files.

 

I realize that there are Automaters on my Mac, there are batch scripts in Photoshop and Fireworks, even a really cool Mac app called iConify(iOS only) but none of those methods meet all my requirements.  I decided to use ImageMagick as my image conversion tool.  Let me give you a few reasons for my choice.

  1. ImageMagick is open source
  2. Runs on UNIX, Mac OS X, Windows, iOS
  3. Has command Line processing

After choosing my tool, I set out to make this process as automated as possible.  I am a Mac user, so I wrote a bash script to handle the workload.  The bash script will organize my projects, move them around to my local storage, push to Git Hub, and now to build images for my project.

Here is how it works:

convert -geometry 114×114 -quality 100 appicon.png resources/android/appicon.png

This command executes the ImageMagick command CONVERT which takes a file called appicon.png (I have this sized at 512 x 512), resizes it to 114×114 and outputs it to my android folder with the name appicon.png at 100 percent of the quality of the original image.

I repeat this for each of my file sizes (check out my other post for more of the sizes) needed and we are done.  I just keep adding to this script for other images.

Hope this speeds your image building process.

Here is my full script:

#!/bin/sh
# **********************************************************
#  convertImages.sh
# 
#
#  Created by Greg Mccormick on 3/25/12.
#  Copyright (c) 2012 Crushmedia, LLC. All rights reserved.
# **********************************************************

# Set your workspace below
#
# add 3 files to your project folder - same level as the tiapp.xml
# icon file should be named app icon.png
# default landscape should be named default_L.png
# default portrait should be named default_P.png
# make note of the exact name of your project in your workspace
#
# **********************************************************

clear
#update the path to your project workspace here
# -tiProjectPath = '~/Documents/\ Workspace/'
echo "#######################################################"
echo " Created by Greg Mccormick on 3/25/12."
echo " Copyright (c) 2012 Crushmedia,LLC. All rights reserved."
echo "#######################################################"
#get the exact app name as it is in the tifolder
echo "Enter the App Name "
read -e APPNAME
# go to the project space - change this to your path
cd ~/Documents/\ Workspace/
cd $APPNAME

#remove the current iPhone and android folders and all the files in them
rm -rf ./Resources/iphone
rm -rf ./Resources/android

mkdir ./Resources/iphone
mkdir ./Resources/android
mkdir ./Resources/android/res-long-port-hdpi
mkdir ./Resources/android/res-long-port-ldpi
mkdir ./Resources/android/res-notlong-port-hdpi
mkdir ./Resources/android/res-notlong-port-ldpi
mkdir ./Resources/android/res-notlong-port-mdpi
mkdir ./Resources/android/res-notlong-land-mdpi
mkdir ./Resources/android/res-notlong-land-ldpi
mkdir ./Resources/android/res-notlong-land-hdpi
mkdir ./Resources/android/res-long-land-ldpi
mkdir ./Resources/android/res-long-land-hdpi

convert -geometry 512x512 -quality 100 appicon.png ./Resources/iphone/appicon@512.png
convert -geometry 114x114 -quality 100 appicon.png ./Resources/iphone/appicon@2x.png
convert -geometry 29x29 -quality 100 appicon.png ./Resources/iphone/appicon-Small.png
convert -geometry 50x50 -quality 100 appicon.png ./Resources/iphone/appicon-Small-50.png
convert -geometry 72x72 -quality 100 appicon.png ./Resources/iphone/appicon-72.png
convert -geometry 57x57 -quality 100 appicon.png ./Resources/iphone/appicon.png
convert -geometry 144x144 -quality 100 appicon.png ./Resources/iphone/appicon-144.png
convert -geometry 128x128 -quality 100 appicon.png ./Resources/android/appicon.png
convert -geometry 1024x748 -quality 100 default_L.png ./Resources/iphone/Default-Landscape.png
convert -geometry 768x1004 -quality 100 default_L.png ./Resources/iphone/Default-Portrait.png
convert -geometry 319x480 -quality 100 default_L.png ./Resources/iphone/Default.png
convert -geometry 639x960 -quality 100 default_L.png ./Resources/iphone/Default@2x.png
convert -geometry 480x800 -quality 100 default_P.png ./Resources/android/res-long-port-hdpi/default.png
convert -geometry 240x400 -quality 100 default_P.png ./Resources/android/res-long-port-ldpi/default.png
convert -geometry 480x800 -quality 100 default_P.png ./Resources/android/res-notlong-port-hdpi/default.png
convert -geometry 240x320 -quality 100 default_P.png ./Resources/android/res-notlong-port-ldpi/default.png
convert -geometry 320x480 -quality 100 default_P.png ./Resources/android/res-notlong-port-mdpi/default.png
convert -geometry 480x320 -quality 100 default_L.png ./Resources/android/res-notlong-land-mdpi/default.pnp
convert -geometry 639x960 -quality 100 default_L.png ./Resources/android/res-notlong-land-ldpi/default.png
convert -geometry 800x480 -quality 100 default_L.png ./Resources/android/res-notlong-land-hdpi/default.png
convert -geometry 400x240 -quality 100 default_L.png ./Resources/android/res-long-land-ldpi/default.png
convert -geometry 800x480 -quality 100 default_L.png ./Resources/android/res-long-land-hdpi/default.png

Greg Mccormick is Founder of CRUSHMEDIA.NET, a full service mobile development company located in Manhattan.