Skip to content

Instantly share code, notes, and snippets.

@Arood
Created October 10, 2012 18:11
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save Arood/3867270 to your computer and use it in GitHub Desktop.
Save Arood/3867270 to your computer and use it in GitHub Desktop.
Convert iPhone-resources to Android (for Titanium)
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/Default@2x.png 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!"
@Arood
Copy link
Author

Arood commented Oct 10, 2012

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?)

@Arood
Copy link
Author

Arood commented Oct 24, 2012

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