HTC Android Splasher

Version: v0.1

Summary: A quick script a threw together to allow Mac or Linux users to create and flash splash screens for their HTC Android phones.

Requirements:

Code:

#!/bin/bash

##Written by Blake Johnson
##Website: http://www.blakeanthonyjohnson.com/
##Script requires ImageMagick and nbimg to be installed and located in $PATH.

#Convert image to 24-bit bitmap.
echo -n "Converting image to 24-bit bitmap...   "
convert "$1" "/tmp/$1.bmp"
convert "/tmp/$1.bmp" +matte "/tmp/$1.bmp"
echo "[Done]"
echo

#Check image dimensions.
echo -n "Verifying image dimensions...   "
ImageInfo=`identify "/tmp/$1.bmp"`
if [[ "$ImageInfo" =~ "480x800" ]]
then
	echo "[Done]"
	echo "Dimensions (480x800) verified for the following phones: HTC Evo, HTC Desire"
elif [[ "$ImageInfo" =~ "320x480" ]]
then
	echo "[Done]"
	echo "Dimensions (320x480) verified for the following phones: HTC Hero"
else
	echo "Unable to verifiy proper dimensions.  Please make sure the image dimensions are correct."
	exit
fi
echo

#Convert to splash image.
echo -n "Converting verified image to splash format...   "
nbimg -F "/tmp/$1.bmp" > /dev/null 2>&1
echo "[Done]"
echo

#Check if they want it flashed via Fastboot, or just copied.
echo "Please select what should be done with the resulting image."
echo "1. Copy image to Desktop."
echo "2. Write image to phone."
echo
read -p "Please select an option. (1, 2)?"
if [[ $REPLY == "1" ]]
then
	echo "You have selected Fastboot mode."
	MODE='write'
elif [[ $REPLY == "2" ]]
then
	echo "You have selected copy-to-Desktop."
	MODE='copy'
else
	echo "Unknown selection.  Exiting."
	exit
fi
echo

##Perform the selected action.
if [[ "${MODE}" == "write" ]]
then
	echo "Launching the Fastboot command...  Please put phone into Fastboot mode."
	fastboot flash splash1 "/tmp/$1.bmp.nb"
	echo "Spash screen has been written successfully."
elif [[ "${MODE}" =~ "copy" ]]
then
	#Copy converted image to Desktop.
	echo -n "Copying converted splash image to Desktop...   "
	cp "/tmp/$1.bmp.nb" "$HOME/Desktop/$1.nb"
	echo "[Done]"
else
	echo "Unknown variable passed to last step."
	exit
fi

Changes:
v0.1: Initial Release

Leave a Reply

Your email address will not be published.