Files
pqAutomationApp/assets/icon_check.bat
xinzhu.yin c157e774e5 1.1.0版本
2026-04-16 16:51:05 +08:00

93 lines
2.2 KiB
Batchfile

@echo off
setlocal ENABLEDELAYEDEXPANSION
:: ------------------------------------------------------------
:: Select ico file via GUI
:: ------------------------------------------------------------
for /f "delims=" %%A in ('powershell -command ^
"Add-Type -AssemblyName System.Windows.Forms | Out-Null; $f=New-Object Windows.Forms.OpenFileDialog; $f.Filter='Icon (*.ico)|*.ico'; if($f.ShowDialog() -eq 'OK'){Write-Output $f.FileName}"') do (
set ICO=%%A
)
if "%ICO%"=="" (
echo No file selected.
pause
exit /b
)
echo Checking icon: %ICO%
echo -----------------------------------------
:: ------------------------------------------------------------
:: Extract bytes via PowerShell (safe for PNG-ICON)
:: ------------------------------------------------------------
for /f "tokens=* delims=" %%B in ('powershell -command ^
"[System.IO.File]::ReadAllBytes('%ICO%') -join ' '"') do (
set RAW=%%B
)
:: Convert byte list into array
set i=0
for %%b in (%RAW%) do (
set BYTE[!i!]=%%b
set /a i+=1
)
set /a LEN=i
:: ICONDIR.Count = bytes 4-5
set /a COUNT=BYTE[4] + BYTE[5]*256
echo Total frames: %COUNT%
echo.
if %COUNT% LEQ 0 (
echo ERROR: Invalid icon or no frames.
pause
exit /b
)
set HAS256=0
set FIRST256=0
echo Frame list:
echo -----------------------------------------
:: Each ICONDIRENTRY = 16 bytes starting at offset 6
for /l %%I in (0,1,%COUNT%-1) do (
set /a OFFSET=6 + 16 * %%I
set W=!BYTE[%OFFSET%]!
set H=!BYTE[%OFFSET%+1]!
if "!W!"=="0" set W=256
if "!H!"=="0" set H=256
echo Frame %%I = !W! x !H!
if "!W!"=="256" if "!H!"=="256" (
set HAS256=1
if %%I==0 set FIRST256=1
)
)
echo.
echo -----------------------------------------
if %HAS256%==0 (
echo ERROR: No 256x256 frame found.
echo This is why NSIS and Windows show a small icon.
pause
exit /b
)
if %FIRST256%==0 (
echo WARNING: 256x256 exists but is NOT frame 0.
echo This causes small icons in NSIS installers.
echo You should reorder frames so 256x256 is the first frame.
pause
exit /b
)
echo SUCCESS: 256x256 frame exists AND is the first frame.
echo Icon is well-structured.
pause
exit /b