56 lines
No EOL
1.4 KiB
Bash
Executable file
56 lines
No EOL
1.4 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Check if input file is provided
|
|
if [ $# -eq 0 ]; then
|
|
echo "Usage: $0 <input.svg>"
|
|
exit 1
|
|
fi
|
|
|
|
input_file="$1"
|
|
# filename=$(basename "$input_file" .svg)
|
|
filename="appicon_foreground"
|
|
output_dir="Platforms/Android/Resources"
|
|
|
|
# DPI configurations
|
|
# Format: [directory_name, scale_percentage]
|
|
declare -A dpi_configs=(
|
|
["mipmap-mdpi"]="100"
|
|
["mipmap-hdpi"]="150"
|
|
["mipmap-xhdpi"]="200"
|
|
["mipmap-xxhdpi"]="300"
|
|
["mipmap-xxxhdpi"]="400"
|
|
)
|
|
|
|
# Check if required tools are installed
|
|
if ! command -v inkscape &> /dev/null; then
|
|
echo "Error: Inkscape is required but not installed. Install using:"
|
|
echo "sudo pacman -S inkscape"
|
|
exit 1
|
|
fi
|
|
|
|
# Create output directory structure
|
|
mkdir -p "$output_dir"
|
|
for dpi in "${!dpi_configs[@]}"; do
|
|
mkdir -p "$output_dir/$dpi"
|
|
done
|
|
|
|
# Get base size - let's use 48px as default mdpi size for app icons
|
|
# You can adjust this base size as needed
|
|
BASE_SIZE=48
|
|
|
|
# Export for each DPI
|
|
for dpi in "${!dpi_configs[@]}"; do
|
|
scale=${dpi_configs[$dpi]}
|
|
# Calculate new size using pure bash arithmetic
|
|
new_size=$(( BASE_SIZE * scale / 100 ))
|
|
|
|
echo "Converting for $dpi (scale: ${scale}%)"
|
|
|
|
inkscape --export-type="png" \
|
|
--export-filename="$output_dir/$dpi/${filename}.png" \
|
|
--export-width="$new_size" \
|
|
--export-height="$new_size" \
|
|
"$input_file"
|
|
done
|
|
|
|
echo "Conversion complete! Files exported to $output_dir/" |