Script to create Android Application Icons

On Linux/Ubuntu, run below script as,

$ image.png

#argument image should be with png format

#cleanup previous 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/

convert $ICON_NAME -resize 192x192 $DIR_TO_SAVE_ICONS/drawable-xxxhdpi/$ICON_NAME
convert $ICON_NAME -resize 144x144 $DIR_TO_SAVE_ICONS/drawable-xxhdpi/$ICON_NAME
convert $ICON_NAME -resize 96x96 $DIR_TO_SAVE_ICONS/drawable-xhdpi/$ICON_NAME
convert $ICON_NAME -resize 72x72 $DIR_TO_SAVE_ICONS/drawable-hdpi/$ICON_NAME
convert $ICON_NAME -resize 48x48 $DIR_TO_SAVE_ICONS/drawable-mdpi/$ICON_NAME
convert $ICON_NAME -resize 36x36 $DIR_TO_SAVE_ICONS/drawable-ldpi/$ICON_NAME

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

zip -r $ .

echo "Icon zip $ is ready at $DIR_TO_SAVE_ICONS"

Extract above generated .zip inside res folder of application source

Leave a Comment