Created
April 21, 2025 19:30
-
-
Save ChandanShakya/7256100159a8b3e08628bd212be10768 to your computer and use it in GitHub Desktop.
SVG to App Icons & Splash Screens Generator (Inkscape + ImageMagick)
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 | |
INPUT="app-icon.svg" | |
OUTPUT_DIR="./images/icons" | |
TEMP_ICON="icon.png" | |
TEMP_ICON_SIZE=1024 | |
mkdir -p "$OUTPUT_DIR" | |
declare -A icon_sizes=( | |
["72x72"]=1 | |
["96x96"]=1 | |
["128x128"]=1 | |
["144x144"]=1 | |
["152x152"]=1 | |
["192x192"]=1 | |
["384x384"]=1 | |
["512x512"]=1 | |
) | |
declare -A splash_sizes=( | |
["640x1136"]=1 | |
["750x1334"]=1 | |
["828x1792"]=1 | |
["1125x2436"]=1 | |
["1242x2208"]=1 | |
["1242x2688"]=1 | |
["1536x2048"]=1 | |
["1668x2224"]=1 | |
["1668x2388"]=1 | |
["2048x2732"]=1 | |
) | |
echo "π¨ Generating icons from $INPUT..." | |
for size in "${!icon_sizes[@]}"; do | |
width=${size%x*} | |
height=${size#*x} | |
output="$OUTPUT_DIR/icon-${size}.png" | |
inkscape "$INPUT" --export-width=$width --export-height=$height --export-filename="$output" > /dev/null 2>&1 | |
echo "β $output" | |
done | |
echo "" | |
echo "π― Generating splash screens..." | |
# Step 1: Generate a single high-res icon PNG to center in splash screens | |
inkscape "$INPUT" --export-width=$TEMP_ICON_SIZE --export-height=$TEMP_ICON_SIZE --export-filename="$TEMP_ICON" > /dev/null 2>&1 | |
for size in "${!splash_sizes[@]}"; do | |
width=${size%x*} | |
height=${size#*x} | |
output="$OUTPUT_DIR/splash-${size}.png" | |
magick -size ${width}x${height} canvas:white "$TEMP_ICON" -gravity center -composite "$output" | |
echo "β $output" | |
done | |
# Cleanup | |
rm "$TEMP_ICON" | |
echo "" | |
echo "β All icons and splash screens generated in $OUTPUT_DIR" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment