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/

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

Android Android Commands Android Java Applications Application Libraries Bash / Shell Scripts Bluetooth driver Build Frameworks Commands and Packages Core Kernel C Programs Development Environment Setup Documents / Books Errors & Failures File Systems Framebuffer / Display Driver git Go Language Programs Hardware Platforms Home Kernel & Device Drivers Kernel Booting and Porting Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL NDK / Middleware / HAL Network Driver OS Concepts PHP Procfs Filesystem Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply