Last active
July 8, 2024 21:36
-
-
Save Kishanjvaghela/8ec54f66c322d8d6940b4c0d1a58098d to your computer and use it in GitHub Desktop.
Create Image drawable for all resolutions
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
if [ $# -eq 0 ]; then | |
echo "No arguments supplied" | |
else if [ -f "$1" ]; then | |
echo " Creating different dimensions (dips) of "$1" ..." | |
mkdir -p drawable-xxhdpi | |
mkdir -p drawable-xhdpi | |
mkdir -p drawable-hdpi | |
mkdir -p drawable-mdpi | |
if [ $1 = "ic_launcher.png" ]; then | |
echo " App icon detected" | |
convert ic_launcher.png -resize 144x144 drawable-xxhdpi/ic_launcher.png | |
convert ic_launcher.png -resize 96x96 drawable-xhdpi/ic_launcher.png | |
convert ic_launcher.png -resize 72x72 drawable-hdpi/ic_launcher.png | |
convert ic_launcher.png -resize 48x48 drawable-mdpi/ic_launcher.png | |
rm -i ic_launcher.png | |
else | |
convert $1 -resize 67% drawable-xhdpi/$1 | |
convert $1 -resize 50% drawable-hdpi/$1 | |
convert $1 -resize 33% drawable-mdpi/$1 | |
mv $1 drawable-xxhdpi/$1 | |
fi | |
echo " Done" | |
else | |
echo "$1 not found." | |
fi | |
fi |
Nevermind, that last fi
should in fact be there
@Kishanjvaghela Can you consider releasing it under some open license, for example GNU GPL v3? See https://choosealicense.com/
I want to include it as a part of a project (Android app) and as it is fully copyrighted I am not allowed to do this.
@matkoniecz Thanks for the suggestion.
https://github.com/Kishanjvaghela/drawable-converter
Please check it. Let me know its working or not for you.
Thanks for sharing this. It works great.
I've forked this gist and added xxxhdpi drawable generation. Also, added better documentation.
Here's my fork: https://gist.github.com/Abdallah-Abdelazim/af99647e1f9542fd4b4fa770c508c335
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's a great addition 👍
There's an extra
fi
at the end I think but everything else is on point, going to edit the StackOverflow answer now