#!/bin/bash

# Input texture filename
INPUT_TEXTURE="marble-tile.jpg"

# Check if input file exists
if [ ! -f "$INPUT_TEXTURE" ]; then
    echo "Error: Input texture '$INPUT_TEXTURE' not found!"
    exit 1
fi

# Define common screen resolutions
declare -A RESOLUTIONS=(
    ["HD_1280x720"]="1280x720"
    ["FHD_1920x1080"]="1920x1080"
    ["QHD_2560x1440"]="2560x1440"
    ["4K_3840x2160"]="3840x2160"
    ["Ultrawide_3440x1440"]="3440x1440"
)

echo "Generating tiled marble backgrounds..."

for name in "${!RESOLUTIONS[@]}"; do
    res="${RESOLUTIONS[$name]}"
    output_file="bg_${name}_${res}.jpg"
echo $output_file
    # ImageMagick command to tile the texture over the target dimension
    convert "$INPUT_TEXTURE" -size "$res" tile:"$INPUT_TEXTURE" "$output_file"
    
    echo "Created: $output_file"
done

echo "All backgrounds generated successfully!"