aluf/scripts/generate_icons.bat

48 lines
1.3 KiB
Batchfile

@echo off
setlocal
:: Arguments passed from CMake:
:: %1 = Path to magick.exe
:: %2 = Source Image
:: %3 = Destination Icon
set "MAGICK_EXE=%~1"
set "SOURCE_IMG=%~2"
set "DEST_ICO=%~3"
:: --- FIX FOR MISSING DELEGATES / REGISTRY ERRORS ---
:: The x86 ImageMagick on ARM64 often fails to find the registry keys.
:: We extract the directory from the executable path and set MAGICK_HOME manually.
for %%I in ("%MAGICK_EXE%") do set "MAGICK_DIR=%%~dpI"
:: Remove trailing backslash for safety (optional but cleaner)
if "%MAGICK_DIR:~-1%"=="\" set "MAGICK_DIR=%MAGICK_DIR:~0,-1%"
set "MAGICK_HOME=%MAGICK_DIR%"
set "MAGICK_CONFIGURE_PATH=%MAGICK_DIR%"
set "MAGICK_CODER_MODULE_PATH=%MAGICK_DIR%\modules\coders"
:: ---------------------------------------------------
:: 1. Validate Source
if not exist "%SOURCE_IMG%" (
echo [ERROR] Icon source not found at: %SOURCE_IMG%
exit /b 1
)
:: 2. Ensure Destination Directory Exists
if not exist "%~dp3" mkdir "%~dp3"
:: 3. Generate the .ico
:: We create a multi-layer ICO with standard Windows sizes
echo [ICONS] Generating Windows Icon: %DEST_ICO%
"%MAGICK_EXE%" "%SOURCE_IMG%" -define icon:auto-resize=256,128,64,48,32,16 "%DEST_ICO%"
if %errorlevel% neq 0 (
echo [ERROR] ImageMagick failed to generate icon.
exit /b %errorlevel%
)
echo [SUCCESS] Icon generated.
exit /b 0