Script to create Android Application Icons

On Linux/Ubuntu, run below script as,

$ make_android_icon.sh image.png

————————————————————————————-

#!/bin/sh

#argument image should be with png format

#cleanup previous icons
DIR_TO_SAVE_ICONS=$PWD/android_icons
rm -rf $DIR_TO_SAVE_ICONS
ICON_NAME=$1 #take icon name as first argument

echo “Creating android icons of different dimensions for $ICON_NAME”

mkdir -p $DIR_TO_SAVE_ICONS/drawable-xxxhdpi/
mkdir -p $DIR_TO_SAVE_ICONS/drawable-xxhdpi/
mkdir -p $DIR_TO_SAVE_ICONS/drawable-xhdpi/
mkdir -p $DIR_TO_SAVE_ICONS/drawable-hdpi/
mkdir -p $DIR_TO_SAVE_ICONS/drawable-mdpi/
mkdir -p $DIR_TO_SAVE_ICONS/drawable-ldpi/

READ  Android Build configurations

convert $ICON_NAME -resize 192×192 $DIR_TO_SAVE_ICONS/drawable-xxxhdpi/$ICON_NAME
convert $ICON_NAME -resize 144×144 $DIR_TO_SAVE_ICONS/drawable-xxhdpi/$ICON_NAME
convert $ICON_NAME -resize 96×96 $DIR_TO_SAVE_ICONS/drawable-xhdpi/$ICON_NAME
convert $ICON_NAME -resize 72×72 $DIR_TO_SAVE_ICONS/drawable-hdpi/$ICON_NAME
convert $ICON_NAME -resize 48×48 $DIR_TO_SAVE_ICONS/drawable-mdpi/$ICON_NAME
convert $ICON_NAME -resize 36×36 $DIR_TO_SAVE_ICONS/drawable-ldpi/$ICON_NAME

#create a zip to copy to android app, res folder

cd $DIR_TO_SAVE_ICONS
zip -r $ICON_NAME.zip .

echo “Icon zip $ICON_NAME.zip is ready at $DIR_TO_SAVE_ICONS”

==================================================================

Extract above generated .zip inside res folder of application source

Leave a Reply

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