#!/bin/bash
# Generate multiple icon sizes from the source icon for better GNOME integration

set -e

SOURCE_ICON="pyPhotoAlbum/icons/icon.png"
ICONS_DIR="pyPhotoAlbum/icons"

# Check if source icon exists
if [ ! -f "$SOURCE_ICON" ]; then
    echo "Error: Source icon not found at $SOURCE_ICON"
    exit 1
fi

# Check if ImageMagick is installed
if ! command -v convert &> /dev/null; then
    echo "ImageMagick is not installed. Please install it:"
    echo "  Fedora:     sudo dnf install ImageMagick"
    echo "  Arch/Cachy: sudo pacman -S imagemagick"
    echo "  Ubuntu:     sudo apt install imagemagick"
    exit 1
fi

echo "Generating icon sizes for GNOME integration..."

# Standard icon sizes for freedesktop.org icon theme specification
SIZES=(16 22 24 32 48 64 128 256 512)

for size in "${SIZES[@]}"; do
    output_file="${ICONS_DIR}/icon-${size}x${size}.png"
    echo "  Creating ${size}x${size} icon..."
    convert "$SOURCE_ICON" -resize "${size}x${size}" "$output_file"
done

# Create scalable SVG if needed (optional)
# This would require inkscape or another tool

echo ""
echo "Icon generation complete!"
echo "Generated icons:"
ls -lh "${ICONS_DIR}"/icon-*.png

echo ""
echo "You can now install these icons using ./install.sh"
