aboutsummaryrefslogtreecommitdiff
path: root/Scripts/Convert-EXR-Assets.ps1
blob: e0faed63c321849ad9d6e7b199c3c34ca172ff15 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Add-Type -AssemblyName System.Windows.Forms

# Modern folder picker (better looking dialog)
$dialog = New-Object System.Windows.Forms.OpenFileDialog
$dialog.Title = "Select a folder"
$dialog.CheckFileExists = $false
$dialog.CheckPathExists = $true
$dialog.Filter = "Folders|*.thisfolderisnotreal"
$dialog.FileName = "SELECT FOLDER"

if ($dialog.ShowDialog() -ne [System.Windows.Forms.DialogResult]::OK) {
    Write-Host "No folder selected, exiting..."
    pause
    exit
}

$targetDir = Split-Path -Path $dialog.FileName -Parent
Write-Host "`nSelected Directory: $targetDir`n"

# Get all EXR files
$exrFiles = Get-ChildItem -Path $targetDir -Filter *.exr -File

if ($exrFiles.Count -eq 0) {
    Write-Host "No EXR files found in this directory!"
    pause
    exit
}

Write-Host "Found $($exrFiles.Count) EXR files, starting conversion..."

# Convert
foreach ($file in $exrFiles) {
    $inputPath = $file.FullName
    $outputPath = Join-Path $targetDir ($file.BaseName + ".png")

    & ffmpeg -i $inputPath -vf "scale=1024:-1:flags=lanczos" -pix_fmt rgb24 -compression_level 6 -y $outputPath

    Write-Host "Converted: $($file.Name)"
}

Write-Host "`nAll done!"
pause