Initial Dansori character workspace
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Out,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Chroma
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$generatedRoot = "C:\Users\ekeer\.codex\generated_images\019f264c-a00f-7d81-ab4c-aa0d0c7fc422"
|
||||
$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"
|
||||
|
||||
$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 (Get-Location) $Out
|
||||
$chromaPath = Join-Path (Get-Location) $Chroma
|
||||
$outDir = Split-Path -Parent $outPath
|
||||
$chromaDir = Split-Path -Parent $chromaPath
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
|
||||
New-Item -ItemType Directory -Force -Path $chromaDir | Out-Null
|
||||
|
||||
Copy-Item -LiteralPath $latest.FullName -Destination $chromaPath -Force
|
||||
|
||||
& $python $removeScript `
|
||||
--input $chromaPath `
|
||||
--out $outPath `
|
||||
--auto-key border `
|
||||
--tolerance 96 `
|
||||
--force
|
||||
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
$bmp = [System.Drawing.Bitmap]::FromFile($outPath)
|
||||
try {
|
||||
$w = $bmp.Width
|
||||
$h = $bmp.Height
|
||||
$cornerAlpha = @(
|
||||
$bmp.GetPixel(0, 0).A,
|
||||
$bmp.GetPixel($w - 1, 0).A,
|
||||
$bmp.GetPixel(0, $h - 1).A,
|
||||
$bmp.GetPixel($w - 1, $h - 1).A
|
||||
) -join ","
|
||||
[PSCustomObject]@{
|
||||
Source = $latest.FullName
|
||||
Out = $outPath
|
||||
Width = $w
|
||||
Height = $h
|
||||
PixelFormat = $bmp.PixelFormat
|
||||
CornerAlpha = $cornerAlpha
|
||||
}
|
||||
}
|
||||
finally {
|
||||
$bmp.Dispose()
|
||||
}
|
||||
Reference in New Issue
Block a user