Files
jiapuapp/tests/g01-asset-alpha-audit.ps1
T
2026-07-13 17:31:11 +08:00

36 lines
1.3 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
Add-Type -AssemblyName System.Drawing
$assets = @(
'static/assets/foundation/transparent/meta-location.png',
'static/assets/foundation/transparent/meta-member.png',
'static/assets/foundation/transparent/meta-admin.png',
'static/assets/modules/genealogy/transparent/current-seal-frame.png',
'static/assets/modules/genealogy/transparent/row-seal-frame.png',
'static/assets/modules/genealogy/transparent/create-cloud.png'
)
foreach ($asset in $assets) {
$bitmap = [System.Drawing.Bitmap]::FromFile((Join-Path $root $asset))
$width = [int]$bitmap.Width
$height = [int]$bitmap.Height
$corners = @(
$bitmap.GetPixel(0, 0).A,
$bitmap.GetPixel(($width - 1), 0).A,
$bitmap.GetPixel(0, ($height - 1)).A,
$bitmap.GetPixel(($width - 1), ($height - 1)).A
)
$visiblePixels = 0
for ($y = 0; $y -lt $height; $y++) {
for ($x = 0; $x -lt $width; $x++) {
if ($bitmap.GetPixel($x, $y).A -gt 24) { $visiblePixels++ }
}
}
$bitmap.Dispose()
if (($corners | Where-Object { $_ -ne 0 }).Count -ne 0) { throw "$asset has opaque outer corners." }
if ($visiblePixels -lt 80) { throw "$asset has no usable visible artwork." }
Write-Output "PASS $asset transparent corners and visible artwork"
}