param( [Parameter(Mandatory = $true)] [string]$Name ) $ErrorActionPreference = "Stop" $workspace = (Get-Location).ProviderPath $generatedRoot = "C:\Users\ekeer\.codex\generated_images\019f26b6-8f7e-7a50-943f-f9aa9014c335" $python = "C:\Users\ekeer\AppData\Local\Programs\KiCad\10.0\bin\python.exe" $removeScript = "C:\Users\ekeer\.codex\skills\.system\imagegen\scripts\remove_chroma_key.py" if ($Name -notmatch '^isabel_body_bikini_[A-Za-z0-9_]+\.png$') { throw "Unexpected Isabel bikini filename: $Name" } $latest = Get-ChildItem -LiteralPath $generatedRoot -Recurse -File -Filter *.png | Sort-Object LastWriteTime -Descending | Select-Object -First 1 if (-not $latest) { throw "No generated PNG found under $generatedRoot" } $outPath = Join-Path $workspace (Join-Path "Isabel\Variations\Bikini\Images" $Name) $chromaPath = Join-Path $workspace (Join-Path "tmp\imagegen" "$Name.chromakey.png") New-Item -ItemType Directory -Force -Path (Split-Path -Parent $outPath) | Out-Null New-Item -ItemType Directory -Force -Path (Split-Path -Parent $chromaPath) | Out-Null Copy-Item -LiteralPath $latest.FullName -Destination $chromaPath -Force & $python $removeScript ` --input $chromaPath ` --out $outPath ` --auto-key border ` --soft-matte ` --transparent-threshold 12 ` --opaque-threshold 220 ` --despill Add-Type -AssemblyName System.Drawing $bmp = [System.Drawing.Bitmap]::FromFile($outPath) try { [PSCustomObject]@{ Source = $latest.FullName Chroma = $chromaPath Out = $outPath Width = $bmp.Width Height = $bmp.Height PixelFormat = $bmp.PixelFormat CornerAlpha = (@( $bmp.GetPixel(0, 0).A, $bmp.GetPixel($bmp.Width - 1, 0).A, $bmp.GetPixel(0, $bmp.Height - 1).A, $bmp.GetPixel($bmp.Width - 1, $bmp.Height - 1).A ) -join ",") } } finally { $bmp.Dispose() }