Last active
March 18, 2024 00:48
-
-
Save unique1984/d2931000b440e768a576192329e728af to your computer and use it in GitHub Desktop.
Flutter application logo creation
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
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.