Skip to content

Instantly share code, notes, and snippets.

@trinnguyen
Created September 7, 2019 14:56
Show Gist options
  • Save trinnguyen/0f6f0208b43ef0afc42ece7ac3c2eaf8 to your computer and use it in GitHub Desktop.
Save trinnguyen/0f6f0208b43ef0afc42ece7ac3c2eaf8 to your computer and use it in GitHub Desktop.
Bash script to resize ios icons for cordova project (personal usage)
#!/usr/bin/env bash
# usage: sh resize.sh [PATH_TO_ICON_FOLDER]
export MAGICK_HOME="$HOME/opt/ImageMagick-7.0.8"
export DYLD_LIBRARY_PATH="$MAGICK_HOME/lib/"
src=$1
originfilepath="${src}/180x180.png"
sizes=('20' '29' '40' '50' '57' '60' '58' '80' '72' '76' '87' '100' '114' '120' '144' '152' '167' '180' '1024')
if test -f ${originfilepath}; then
for s in ${sizes[@]}; do
filepath="${src}/${s}x${s}.png"
if test -f ${filepath}; then
echo "Ignored. File exist: ${filepath}"
else
echo "Generate file: ${filepath}"
cmd="convert ${originfilepath} -resize ${s}x${s} ${filepath}"
echo "\t execute cmd: ${cmd}"
$(${cmd})
fi
done
else
echo "Original image file does not exist"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment