Initial Dansori character workspace
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
|
||||
$mds = @(
|
||||
".\Isabel\Hair\Hair.md",
|
||||
".\Isabel\Base\Base.md",
|
||||
".\Isabel\Accessories\Accessories.md",
|
||||
".\Isabel\Variations\Bikini\Bikini.md",
|
||||
".\Isabel\Variations\CeoPantsuit\CeoPantsuit.md"
|
||||
)
|
||||
|
||||
$items = New-Object System.Collections.Generic.List[object]
|
||||
|
||||
foreach ($md in $mds) {
|
||||
$imageDir = Join-Path (Split-Path -Parent $md) "Images"
|
||||
$expected = Select-String -LiteralPath $md -Pattern '^##\s+(.+\.png)\s*$' |
|
||||
ForEach-Object { $_.Matches[0].Groups[1].Value }
|
||||
|
||||
foreach ($name in $expected) {
|
||||
$path = Join-Path $imageDir $name
|
||||
$exists = Test-Path -LiteralPath $path
|
||||
$record = [ordered]@{
|
||||
md = $md
|
||||
file = $path
|
||||
exists = $exists
|
||||
pixelFormat = $null
|
||||
width = $null
|
||||
height = $null
|
||||
cornerAlpha = $null
|
||||
ok = $false
|
||||
}
|
||||
|
||||
if ($exists) {
|
||||
$bmp = [System.Drawing.Bitmap]::FromFile((Resolve-Path -LiteralPath $path).Path)
|
||||
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
|
||||
)
|
||||
$fmt = $bmp.PixelFormat.ToString()
|
||||
$record.pixelFormat = $fmt
|
||||
$record.width = $w
|
||||
$record.height = $h
|
||||
$record.cornerAlpha = ($cornerAlpha -join ",")
|
||||
$record.ok = ($fmt -eq "Format32bppArgb" -and ($cornerAlpha | Where-Object { $_ -ne 0 }).Count -eq 0)
|
||||
}
|
||||
finally {
|
||||
$bmp.Dispose()
|
||||
}
|
||||
}
|
||||
|
||||
$items.Add([PSCustomObject]$record)
|
||||
}
|
||||
}
|
||||
|
||||
$summary = [ordered]@{
|
||||
checkedAt = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss K")
|
||||
total = $items.Count
|
||||
existing = ($items | Where-Object { $_.exists }).Count
|
||||
ok = ($items | Where-Object { $_.ok }).Count
|
||||
missing = @($items | Where-Object { -not $_.exists } | Select-Object md, file)
|
||||
failed = @($items | Where-Object { $_.exists -and -not $_.ok } | Select-Object file, pixelFormat, cornerAlpha)
|
||||
byMd = @($items | Group-Object md | ForEach-Object {
|
||||
[PSCustomObject]@{
|
||||
md = $_.Name
|
||||
total = $_.Count
|
||||
ok = @($_.Group | Where-Object { $_.ok }).Count
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$out = ".\Isabel\ISABEL_ASSET_VERIFY.json"
|
||||
$summary | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath $out -Encoding UTF8
|
||||
$summary | ConvertTo-Json -Depth 6
|
||||
Reference in New Issue
Block a user