65 lines
2.2 KiB
PowerShell
65 lines
2.2 KiB
PowerShell
# 调整 TabBar 图标尺寸为 28x28 像素
|
|
Add-Type -AssemblyName System.Drawing
|
|
|
|
$sourceDir = "src/assets/images"
|
|
$targetSize = 28
|
|
|
|
# 需要调整的图标文件列表
|
|
$iconFiles = @(
|
|
"shouye.png",
|
|
"shouye_active.png",
|
|
"cheliang.png",
|
|
"cheliang_active.png",
|
|
"tongji.png",
|
|
"tongji_active.png",
|
|
"wode.png",
|
|
"wode_active.png"
|
|
)
|
|
|
|
foreach ($iconFile in $iconFiles) {
|
|
$sourcePath = Join-Path $sourceDir $iconFile
|
|
$backupPath = Join-Path $sourceDir ($iconFile -replace '\.png$', '_backup.png')
|
|
|
|
if (Test-Path $sourcePath) {
|
|
try {
|
|
# 创建备份
|
|
Copy-Item $sourcePath $backupPath -Force
|
|
Write-Host "已备份: $iconFile"
|
|
|
|
# 加载原始图片
|
|
$originalImage = [System.Drawing.Image]::FromFile((Resolve-Path $sourcePath))
|
|
|
|
# 创建新的 28x28 图片
|
|
$newImage = New-Object System.Drawing.Bitmap($targetSize, $targetSize)
|
|
$graphics = [System.Drawing.Graphics]::FromImage($newImage)
|
|
|
|
# 设置高质量缩放
|
|
$graphics.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
|
|
$graphics.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::HighQuality
|
|
$graphics.PixelOffsetMode = [System.Drawing.Drawing2D.PixelOffsetMode]::HighQuality
|
|
$graphics.CompositingQuality = [System.Drawing.Drawing2D.CompositingQuality]::HighQuality
|
|
|
|
# 绘制缩放后的图片
|
|
$graphics.DrawImage($originalImage, 0, 0, $targetSize, $targetSize)
|
|
|
|
# 保存新图片
|
|
$newImage.Save($sourcePath, [System.Drawing.Imaging.ImageFormat]::Png)
|
|
|
|
# 释放资源
|
|
$graphics.Dispose()
|
|
$newImage.Dispose()
|
|
$originalImage.Dispose()
|
|
|
|
Write-Host "已调整: $iconFile -> 28x28 像素"
|
|
}
|
|
catch {
|
|
Write-Host "调整失败: $iconFile - $($_.Exception.Message)"
|
|
}
|
|
}
|
|
else {
|
|
Write-Host "文件不存在: $iconFile"
|
|
}
|
|
}
|
|
|
|
Write-Host "所有 TabBar 图标调整完成!"
|