forked from jsnbuchanan/crowd-funder-for-time-pwa
fix(build): update ImageMagick commands to use modern v7 syntax
- 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.
This commit is contained in:
@@ -20,9 +20,16 @@ if [ ! -f "$ASSETS_DIR/icon.png" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if ImageMagick is available
|
||||
if ! command -v convert &> /dev/null; then
|
||||
echo "[ERROR] ImageMagick (convert) not found. Please install ImageMagick."
|
||||
# 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"
|
||||
@@ -39,20 +46,35 @@ mkdir -p "$ANDROID_RES_DIR/mipmap-anydpi-v26"
|
||||
|
||||
echo "[INFO] Generating launcher icons..."
|
||||
|
||||
# Function to resize image using the appropriate ImageMagick command
|
||||
resize_image() {
|
||||
local input="$1"
|
||||
local output="$2"
|
||||
local size="$3"
|
||||
|
||||
if [ "$IMAGEMAGICK_CMD" = "magick" ]; then
|
||||
# ImageMagick v7+ syntax
|
||||
magick "$input" -resize "${size}x${size}" "$output"
|
||||
else
|
||||
# ImageMagick v6 syntax
|
||||
convert "$input" -resize "${size}x${size}" "$output"
|
||||
fi
|
||||
}
|
||||
|
||||
# Generate launcher icons for different densities
|
||||
# Android launcher icon sizes: mdpi=48, hdpi=72, xhdpi=96, xxhdpi=144, xxxhdpi=192
|
||||
convert "$ASSETS_DIR/icon.png" -resize 48x48 "$ANDROID_RES_DIR/mipmap-mdpi/ic_launcher.png"
|
||||
convert "$ASSETS_DIR/icon.png" -resize 72x72 "$ANDROID_RES_DIR/mipmap-hdpi/ic_launcher.png"
|
||||
convert "$ASSETS_DIR/icon.png" -resize 96x96 "$ANDROID_RES_DIR/mipmap-xhdpi/ic_launcher.png"
|
||||
convert "$ASSETS_DIR/icon.png" -resize 144x144 "$ANDROID_RES_DIR/mipmap-xxhdpi/ic_launcher.png"
|
||||
convert "$ASSETS_DIR/icon.png" -resize 192x192 "$ANDROID_RES_DIR/mipmap-xxxhdpi/ic_launcher.png"
|
||||
resize_image "$ASSETS_DIR/icon.png" "$ANDROID_RES_DIR/mipmap-mdpi/ic_launcher.png" 48
|
||||
resize_image "$ASSETS_DIR/icon.png" "$ANDROID_RES_DIR/mipmap-hdpi/ic_launcher.png" 72
|
||||
resize_image "$ASSETS_DIR/icon.png" "$ANDROID_RES_DIR/mipmap-xhdpi/ic_launcher.png" 96
|
||||
resize_image "$ASSETS_DIR/icon.png" "$ANDROID_RES_DIR/mipmap-xxhdpi/ic_launcher.png" 144
|
||||
resize_image "$ASSETS_DIR/icon.png" "$ANDROID_RES_DIR/mipmap-xxxhdpi/ic_launcher.png" 192
|
||||
|
||||
# Generate round launcher icons
|
||||
convert "$ASSETS_DIR/icon.png" -resize 48x48 "$ANDROID_RES_DIR/mipmap-mdpi/ic_launcher_round.png"
|
||||
convert "$ASSETS_DIR/icon.png" -resize 72x72 "$ANDROID_RES_DIR/mipmap-hdpi/ic_launcher_round.png"
|
||||
convert "$ASSETS_DIR/icon.png" -resize 96x96 "$ANDROID_RES_DIR/mipmap-xhdpi/ic_launcher_round.png"
|
||||
convert "$ASSETS_DIR/icon.png" -resize 144x144 "$ANDROID_RES_DIR/mipmap-xxhdpi/ic_launcher_round.png"
|
||||
convert "$ASSETS_DIR/icon.png" -resize 192x192 "$ANDROID_RES_DIR/mipmap-xxxhdpi/ic_launcher_round.png"
|
||||
resize_image "$ASSETS_DIR/icon.png" "$ANDROID_RES_DIR/mipmap-mdpi/ic_launcher_round.png" 48
|
||||
resize_image "$ASSETS_DIR/icon.png" "$ANDROID_RES_DIR/mipmap-hdpi/ic_launcher_round.png" 72
|
||||
resize_image "$ASSETS_DIR/icon.png" "$ANDROID_RES_DIR/mipmap-xhdpi/ic_launcher_round.png" 96
|
||||
resize_image "$ASSETS_DIR/icon.png" "$ANDROID_RES_DIR/mipmap-xxhdpi/ic_launcher_round.png" 144
|
||||
resize_image "$ASSETS_DIR/icon.png" "$ANDROID_RES_DIR/mipmap-xxxhdpi/ic_launcher_round.png" 192
|
||||
|
||||
# Create simple launcher XML files (no adaptive icons for now)
|
||||
cat > "$ANDROID_RES_DIR/mipmap-anydpi-v26/ic_launcher.xml" << 'EOF'
|
||||
@@ -72,7 +94,7 @@ cat > "$ANDROID_RES_DIR/mipmap-anydpi-v26/ic_launcher_round.xml" << 'EOF'
|
||||
EOF
|
||||
|
||||
# Create foreground mipmap files for adaptive icons
|
||||
convert "$ASSETS_DIR/icon.png" -resize 108x108 "$ANDROID_RES_DIR/mipmap-anydpi-v26/ic_launcher_foreground.png"
|
||||
resize_image "$ASSETS_DIR/icon.png" "$ANDROID_RES_DIR/mipmap-anydpi-v26/ic_launcher_foreground.png" 108
|
||||
|
||||
echo "[SUCCESS] Generated Android launcher icons:"
|
||||
echo " - mipmap-mdpi/ic_launcher.png (48x48)"
|
||||
|
||||
Reference in New Issue
Block a user