-
-
Save rharter/8679028 to your computer and use it in GitHub Desktop.
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; } | |
IOS_IMAGE_PATH="$1" | |
OUTPUT_PATH="$2" | |
mkdir -p $OUTPUT_PATH/res/drawable-hdpi $OUTPUT_PATH/res/drawable-mdpi $OUTPUT_PATH/res/drawable-xhdpi | |
echo " » Copy all resources to MDPI, this is" | |
echo " the same density as a non-retina iOS device" | |
find "${IOS_IMAGE_PATH}"/* -type f -exec cp {} ${OUTPUT_PATH}/res/drawable-mdpi/ \; | |
echo " » Move the retina resources to XHDPI, which" | |
echo " has the same density as a retina iOS device" | |
find ${OUTPUT_PATH}/res/drawable-mdpi/* -type f -regex ".*@2x.*" -exec mv {} ${OUTPUT_PATH}/res/drawable-xhdpi/ \; | |
echo " » Remove @2x from XHDPI filenames" | |
find ${OUTPUT_PATH}/res/drawable-xhdpi/* -type f -exec bash -c 'file={}; mv $file ${file/@2x/}' \; | |
echo " » Generate HDPI by copying XHDPI and resize these by 75%" | |
cp -R ${OUTPUT_PATH}/res/drawable-xhdpi/* ${OUTPUT_PATH}/res/drawable-hdpi/ | |
find ${OUTPUT_PATH}/res/drawable-hdpi/* -type f -exec mogrify -resize 75% {} \; | |
echo " » Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've updated the gist to support transforming images from a single input directory to standard Android directories instead of Titanium drawable.