Created
October 10, 2012 18:11
-
-
Save Arood/3867270 to your computer and use it in GitHub Desktop.
Convert iPhone-resources to Android (for Titanium)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type mogrify >/dev/null 2>&1 || { echo >&2 "» This script requires mogrify. Please install ImageMagick first!"; exit 1; } | |
rm -rf Resources/android/images | |
mkdir Resources/android/images | |
mkdir Resources/android/images/res-xhdpi | |
mkdir Resources/android/images/res-mdpi | |
echo " » Copying the splash screen" | |
cp Resources/iphone/Default.png Resources/android/images/res-mdpi/default.png | |
cp Resources/iphone/[email protected] Resources/android/images/res-xhdpi/default.png | |
cd Resources/iphone/images | |
echo " » Copying the folder structure so bash won't complain" | |
find ./* -type d -exec mkdir ../../../Resources/android/images/res-mdpi/{} \; | |
find ./* -type d -exec mkdir ../../../Resources/android/images/res-xhdpi/{} \; | |
echo " » Copy all resources to MDPI, this is" | |
echo " the same density as a non-retina iOS device" | |
find ./* -type f -exec cp {} ../../../Resources/android/images/res-mdpi/{} \; | |
cd ../../../Resources/android/images/res-mdpi/ | |
echo " » Move the retina resources to XHDPI, which" | |
echo " has the same density as a retina iOS device" | |
find ./* -type f -regex ".*@2x.*" -exec mv {} ../res-xhdpi/{} \; | |
cd ../res-xhdpi | |
echo " » Remove @2x from XHDPI filenames" | |
find ./* -type f -exec bash -c 'file={}; mv $file ${file/@2x/}' \; | |
cd ../ | |
echo " » Generate HDPI by copying XHDPI and resize these by 75%" | |
mkdir res-hdpi | |
cp -R res-xhdpi/* res-hdpi | |
cd res-hdpi | |
find ./* -type f -exec mogrify -resize 75% {} \; | |
echo " » Done!" |
Scales for HDPI now at least. We'll see if I need to add LDPI or not.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script copies iPhone images (Resources/iphone/images) and splits non-retina and retina graphics into MDPI and XHDPI-densities on Android (Resources/android/images). So I only have to work with the iPhone folders when settings up image resources, this script handles everything else.
To do: Scale images to LDPI and HDPI (if this is even needed?)