Last active
June 20, 2021 21:03
-
-
Save ImaginativeShohag/856ce1cf44e5ab5563264cbeef4fe1f8 to your computer and use it in GitHub Desktop.
Generate Android assets for different pixel density
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
#--------------------------------------------------------------- | |
# Given an xxxhdpi image, this script | |
# creates different dpis resources and the necessary folders | |
# if they don't exist | |
# | |
# Place this script, as well as the source image, inside res | |
# folder and execute it passing the image filename as argument | |
# | |
# Example: | |
# ./drawables_dpis_creation.sh my_cool_xxhdpi_image.png | |
# | |
# Copyright (c) 2016 Ricardo Romao. | |
# This free software comes with ABSOLUTELY NO WARRANTY and | |
# is distributed under GNU GPL v3 license. | |
# | |
# Source: https://github.com/Kishanjvaghela/drawable-converter/blob/master/converter.sh | |
# Help: https://developer.android.com/training/multiscreen/screendensities | |
#--------------------------------------------------------------- | |
if [ $# -eq 0 ]; then | |
echo "No arguments supplied" | |
else if [ -f "$1" ]; then | |
echo " Creating different dimensions (dips) of "$1" ..." | |
mkdir -p drawable-xxxhdpi | |
mkdir -p drawable-xxhdpi | |
mkdir -p drawable-xhdpi | |
mkdir -p drawable-hdpi | |
mkdir -p drawable-mdpi | |
convert $1 -resize 75% drawable-xxhdpi/$1 | |
convert $1 -resize 50% drawable-xhdpi/$1 | |
convert $1 -resize 38% drawable-hdpi/$1 | |
convert $1 -resize 25% drawable-mdpi/$1 | |
mv $1 drawable-xxxhdpi/$1 | |
echo " Done" | |
else | |
echo "$1 not found." | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment