Skip to content

Instantly share code, notes, and snippets.

@unique1984
Last active March 18, 2024 00:48
Show Gist options
  • Save unique1984/d2931000b440e768a576192329e728af to your computer and use it in GitHub Desktop.
Save unique1984/d2931000b440e768a576192329e728af to your computer and use it in GitHub Desktop.
Flutter application logo creation
#!/bin/bash
# Flutter application logo images location!
# WIN : FLUTTER_APP_ROOT\android\app\src\main\res
# LINUX : FLUTTER_APP_ROOT/android/app/src/main/res
function explode {
FULL="$1"
F_PATH=${FULL%/*}
F_BASE=${FULL##*/}
F_NAME=${F_BASE%.*}
F_EXT=${F_BASE##*.}
# echo "fpath="$F_PATH
# echo "fbase="$F_BASE
# echo "fname="$F_NAME
# echo "fextension="$F_EXT
# exit
}
if [ -z $(which convert) ]; then
echo "Install imagemagick"
echo "sudo apt install imagemagick"
exit
fi
if [ -z "$1" ]; then
echo "Select a square png file!"
exit
fi
explode $(pwd)/$1
sizes=(48 72 96 144 192)
directories=(mipmap-mdpi mipmap-hdpi mipmap-xhdpi mipmap-xxhdpi mipmap-xxxhdpi)
if [ ! -d "$F_NAME" ]; then
mkdir "$F_NAME"
fi
for i in `seq 0 4`; do
nthDirectory=$F_NAME/${directories[$i]}
if [ ! -d "$nthDirectory" ]; then
mkdir "$nthDirectory"
fi
nthSize=${sizes[$i]}
convert $1 -resize "$nthSizex$nthSize" "$nthDirectory/ic_launcher.png"
echo "$1 -> "$nthSize"x"$nthSize" -> $nthDirectory/ic_launcher.png"
done
@unique1984
Copy link
Author

unique1984 commented Jun 4, 2021

resim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment