$ErrorActionPreference = "Stop"
$cwebp = (Resolve-Path "libwebp_extract\libwebp-*\bin\cwebp.exe").Path

$filesToConvert = @(
    "Shankari Floor Plan.png",
    "shankari-Aerial-View.jpg",
    "Shankari-CENTRALPARK.jpg",
    "Shankari-Elevation-2.jpg",
    "Shankari-Master-plan.png",
    "shankari-pool.jpg",
    "shankari-Sports-court.jpg",
    "Shriram Logo.png",
    "Shriram-Shankari -2bhk-Floorplan.jpg",
    "Shriram-Shankari -Amenities-01.jpg",
    "Shriram-Shankari -Amenities-02.jpg",
    "Shriram-Shankari -Amenities-04.jpg",
    "Shriram-Shankari -Amenities05-.jpg",
    "Shriram-Shankari -Elevation-2.jpg",
    "Shriram-Shankari -Gallery-1.jpg",
    "Shriram-Shankari -Gallery-2.jpg",
    "Shriram-Shankari -Gallery-3.jpg",
    "Shriram-Shankari -Gallery-4.jpg",
    "Shriram-Shankari -Gallery-5.jpg",
    "Shriram-Shankari -Location.jpg",
    "Shriram-Shankari -Tower Plan-1.jpg",
    "Shriram-Shankari -TOWER PLAN-2.jpg",
    "Shriram-Shankari-Location-map.png",
    "SHRIRAM-Shankari-Park-1.jpg"
)

foreach ($file in $filesToConvert) {
    if (Test-Path $file) {
        # Create webp name but in lowercase, replacing spaces with dashes to be safe
        # Or just use the exact name but with .webp extension
        $outFile = [System.IO.Path]::ChangeExtension($file, ".webp")
        Write-Host "Converting $file to $outFile..."
        & $cwebp -q 80 $file -o $outFile
    }
}
Write-Host "Conversion completed."
