Browse Source
- Replace deprecated 'convert' commands with 'magick' for ImageMagick v7+ - Add automatic version detection with fallback to 'convert' for v6 compatibility - Update generate-android-icons.sh and generate-icons.sh scripts - Eliminate deprecation warnings during Android builds - Maintain backward compatibility for older ImageMagick installations The scripts now automatically detect ImageMagick version and use the appropriate command syntax, eliminating the "convert command is deprecated" warnings while preserving functionality across different ImageMagick versions.pull/165/head
2 changed files with 108 additions and 29 deletions
@ -1,22 +1,79 @@ |
|||||
#!/bin/bash |
#!/bin/bash |
||||
|
|
||||
|
# TimeSafari Android Icon Generation Script (Placeholder Icons) |
||||
|
# Generates placeholder Android launcher icons with "TS" text |
||||
|
# Author: Matthew Raymer |
||||
|
|
||||
|
set -e |
||||
|
|
||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
||||
|
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" |
||||
|
ANDROID_RES_DIR="$PROJECT_ROOT/android/app/src/main/res" |
||||
|
|
||||
|
echo "=== TimeSafari Android Placeholder Icon Generation ===" |
||||
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [INFO] Starting Android placeholder icon generation" |
||||
|
|
||||
|
# Check if ImageMagick is available and determine the correct command |
||||
|
IMAGEMAGICK_CMD="" |
||||
|
if command -v magick &> /dev/null; then |
||||
|
IMAGEMAGICK_CMD="magick" |
||||
|
echo "[INFO] Using ImageMagick v7+ (magick command)" |
||||
|
elif command -v convert &> /dev/null; then |
||||
|
IMAGEMAGICK_CMD="convert" |
||||
|
echo "[INFO] Using ImageMagick v6 (convert command)" |
||||
|
else |
||||
|
echo "[ERROR] ImageMagick not found. Please install ImageMagick." |
||||
|
echo " Arch: sudo pacman -S imagemagick" |
||||
|
echo " Ubuntu: sudo apt-get install imagemagick" |
||||
|
echo " macOS: brew install imagemagick" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
# Create directories if they don't exist |
# Create directories if they don't exist |
||||
mkdir -p android/app/src/main/res/mipmap-mdpi |
mkdir -p "$ANDROID_RES_DIR/mipmap-mdpi" |
||||
mkdir -p android/app/src/main/res/mipmap-hdpi |
mkdir -p "$ANDROID_RES_DIR/mipmap-hdpi" |
||||
mkdir -p android/app/src/main/res/mipmap-xhdpi |
mkdir -p "$ANDROID_RES_DIR/mipmap-xhdpi" |
||||
mkdir -p android/app/src/main/res/mipmap-xxhdpi |
mkdir -p "$ANDROID_RES_DIR/mipmap-xxhdpi" |
||||
mkdir -p android/app/src/main/res/mipmap-xxxhdpi |
mkdir -p "$ANDROID_RES_DIR/mipmap-xxxhdpi" |
||||
|
|
||||
|
# Function to generate placeholder icon using the appropriate ImageMagick command |
||||
|
generate_placeholder_icon() { |
||||
|
local size="$1" |
||||
|
local output="$2" |
||||
|
local pointsize="$3" |
||||
|
|
||||
|
if [ "$IMAGEMAGICK_CMD" = "magick" ]; then |
||||
|
# ImageMagick v7+ syntax |
||||
|
magick -size "${size}x${size}" xc:blue -gravity center -pointsize "$pointsize" -fill white -annotate 0 "TS" "$output" |
||||
|
else |
||||
|
# ImageMagick v6 syntax |
||||
|
convert -size "${size}x${size}" xc:blue -gravity center -pointsize "$pointsize" -fill white -annotate 0 "TS" "$output" |
||||
|
fi |
||||
|
} |
||||
|
|
||||
|
echo "[INFO] Generating placeholder launcher icons..." |
||||
|
|
||||
# Generate placeholder icons using ImageMagick |
# Generate placeholder icons using ImageMagick |
||||
convert -size 48x48 xc:blue -gravity center -pointsize 20 -fill white -annotate 0 "TS" android/app/src/main/res/mipmap-mdpi/ic_launcher.png |
generate_placeholder_icon 48 "$ANDROID_RES_DIR/mipmap-mdpi/ic_launcher.png" 20 |
||||
convert -size 72x72 xc:blue -gravity center -pointsize 30 -fill white -annotate 0 "TS" android/app/src/main/res/mipmap-hdpi/ic_launcher.png |
generate_placeholder_icon 72 "$ANDROID_RES_DIR/mipmap-hdpi/ic_launcher.png" 30 |
||||
convert -size 96x96 xc:blue -gravity center -pointsize 40 -fill white -annotate 0 "TS" android/app/src/main/res/mipmap-xhdpi/ic_launcher.png |
generate_placeholder_icon 96 "$ANDROID_RES_DIR/mipmap-xhdpi/ic_launcher.png" 40 |
||||
convert -size 144x144 xc:blue -gravity center -pointsize 60 -fill white -annotate 0 "TS" android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png |
generate_placeholder_icon 144 "$ANDROID_RES_DIR/mipmap-xxhdpi/ic_launcher.png" 60 |
||||
convert -size 192x192 xc:blue -gravity center -pointsize 80 -fill white -annotate 0 "TS" android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png |
generate_placeholder_icon 192 "$ANDROID_RES_DIR/mipmap-xxxhdpi/ic_launcher.png" 80 |
||||
|
|
||||
|
echo "[INFO] Copying to round versions..." |
||||
|
|
||||
# Copy to round versions |
# Copy to round versions |
||||
cp android/app/src/main/res/mipmap-mdpi/ic_launcher.png android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png |
cp "$ANDROID_RES_DIR/mipmap-mdpi/ic_launcher.png" "$ANDROID_RES_DIR/mipmap-mdpi/ic_launcher_round.png" |
||||
cp android/app/src/main/res/mipmap-hdpi/ic_launcher.png android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png |
cp "$ANDROID_RES_DIR/mipmap-hdpi/ic_launcher.png" "$ANDROID_RES_DIR/mipmap-hdpi/ic_launcher_round.png" |
||||
cp android/app/src/main/res/mipmap-xhdpi/ic_launcher.png android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png |
cp "$ANDROID_RES_DIR/mipmap-xhdpi/ic_launcher.png" "$ANDROID_RES_DIR/mipmap-xhdpi/ic_launcher_round.png" |
||||
cp android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png |
cp "$ANDROID_RES_DIR/mipmap-xxhdpi/ic_launcher.png" "$ANDROID_RES_DIR/mipmap-xxhdpi/ic_launcher_round.png" |
||||
cp android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png |
cp "$ANDROID_RES_DIR/mipmap-xxxhdpi/ic_launcher.png" "$ANDROID_RES_DIR/mipmap-xxxhdpi/ic_launcher_round.png" |
||||
|
|
||||
|
echo "[SUCCESS] Generated Android placeholder launcher icons:" |
||||
|
echo " - mipmap-mdpi/ic_launcher.png (48x48)" |
||||
|
echo " - mipmap-hdpi/ic_launcher.png (72x72)" |
||||
|
echo " - mipmap-xhdpi/ic_launcher.png (96x96)" |
||||
|
echo " - mipmap-xxhdpi/ic_launcher.png (144x144)" |
||||
|
echo " - mipmap-xxxhdpi/ic_launcher.png (192x192)" |
||||
|
echo " - All round versions created" |
||||
|
echo "[SUCCESS] Android placeholder icon generation completed successfully!" |
Loading…
Reference in new issue