Created
September 7, 2019 14:56
-
-
Save trinnguyen/0f6f0208b43ef0afc42ece7ac3c2eaf8 to your computer and use it in GitHub Desktop.
Bash script to resize ios icons for cordova project (personal usage)
This file contains hidden or 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
#!/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