Created
April 9, 2026 22:37
-
-
Save Krzysiu/c39592d5d4d70489e408507d317de7cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| REM ========================================================================= | |
| REM Cute IM-Montage Wrapper v0.1 | |
| REM ========================================================================= | |
| REM | |
| REM WHAT IS THIS? | |
| REM This is a lightweight CLI wrapper for ImageMagick's "montage" tool. | |
| REM It allows you to quickly create contact sheets (grids/mosaics) from | |
| REM multiple images with a user-friendly menu interface. | |
| REM | |
| REM The best way to see the results is to check the samples: | |
| REM https://i.imgur.com/B0Bnl1u.png (generated by this tool). | |
| REM | |
| REM USAGE: | |
| REM Save this script as a .bat file. You can use it in two ways: | |
| REM a) [CLI] Run from command line: script.bat file1.jpg file2.png ... | |
| REM b) [GUI] Drag and drop files directly onto the batch script icon. | |
| REM | |
| REM MENU OPTIONS DESCRIPTION: | |
| REM - Set grid layout: Defines tile arrangement (columns x rows). | |
| REM - Set border: Sets spacing between images and margins. | |
| REM - Set format and quality: Output format choice (JPG, PNG, TIF) | |
| REM and their compression parameters. | |
| REM - Resize: Scales input images before assembly. | |
| REM - Additional CMD: Any extra ImageMagick parameters (e.g., -shadow). | |
| REM - [GENERATE]: Starts the montage creation process. | |
| REM - Exit: Closes the application. | |
| REM | |
| REM REQUIREMENTS: | |
| REM 1. ImageMagick - https://imagemagick.org/script/download.php#windows | |
| REM Use the "static" version. For best performance (speed), | |
| REM the Q8-x64-static.exe version is highly recommended. | |
| REM 2. QuickMenu - Must be in your PATH (crucial for UX). | |
| REM Binary available at: https://github.com/Krzysiu/quickMenu | |
| REM | |
| REM KNOWN LIMITATIONS: | |
| REM If the program is interrupted by ^C, the console color might change. | |
| REM To fix it, just restart the program and use the "Exit" option. | |
| REM | |
| REM Mmmm, coffee: https://buymeacoffee.com/krzysiunet | |
| REM ========================================================================= | |
| @echo off | |
| setlocal enabledelayedexpansion | |
| set "OUT_DIR=%~dp1" | |
| set "ESC=" | |
| echo %ESC%[0m | |
| :: Default values | |
| set "TILES=1x" | |
| set "BORDER=0" | |
| set "FORMAT=JPEG" | |
| set "EXT=jpg" | |
| set "F_OPTS=-quality 80" | |
| set "F_DISP=JPEG q80" | |
| set "RESIZE=100%%" | |
| set "ADD_CMD=" | |
| :MAIN_MENU | |
| set "OPTS=Set grid layout (%TILES%),Set border (+%BORDER%),Set format and quality (%F_DISP%),Resize (%RESIZE%),Additional CMD (%ADD_CMD%),[GENERATE],Exit" | |
| qmenu -t "Cute IM-Montage Wrapper" -c "%OPTS%" | |
| set "CHOICE=%ERRORLEVEL%" | |
| if %CHOICE%==1 goto SET_TILES | |
| if %CHOICE%==2 goto SET_BORDER | |
| if %CHOICE%==3 goto SET_FORMAT | |
| if %CHOICE%==4 goto SET_RESIZE | |
| if %CHOICE%==5 goto SET_ADDITIONAL | |
| if %CHOICE%==6 goto RUN_MAGICK | |
| if %CHOICE%==7 exit /b | |
| :SET_TILES | |
| cls | |
| echo ╔════════════════════════════════════════════════════════════╗ | |
| echo ║ %ESC%[92mGrid layout setting%ESC%[0m ║ | |
| echo ╠═════════════════════╦══════════════════════════════════════╣ | |
| echo ║ Syntax ║ Effect ║ | |
| echo ╠═════════════════════╬══════════════════════════════════════╣ | |
| echo ║ %ESC%[97m2x%ESC%[0m ║ %ESC%[91m2%ESC%[0m columns, automatic rows ║ | |
| echo ║ %ESC%[97mx2%ESC%[0m ║ automatic columns, %ESC%[91m2%ESC%[0m rows ║ | |
| echo ║ %ESC%[97m3x2%ESC%[0m ║ force %ESC%[91m3x2%ESC%[0m, may create multiple files ║ | |
| echo ╚═════════════════════╩══════════════════════════════════════╝ | |
| set /p "TILES=Enter grid layout: %ESC%[91m" | |
| echo %ESC%[0m | |
| goto MAIN_MENU | |
| :SET_BORDER | |
| cls | |
| set /p "BORDER=Enter number: %ESC%[91m" | |
| echo %ESC%[0m | |
| goto MAIN_MENU | |
| :SET_FORMAT | |
| qmenu -t "Select Format" -c "PNG,TIF,JPEG" | |
| if %ERRORLEVEL%==1 goto SET_PNG | |
| if %ERRORLEVEL%==2 goto SET_TIF | |
| if %ERRORLEVEL%==3 goto SET_JPG | |
| goto MAIN_MENU | |
| :SET_PNG | |
| cls | |
| echo Enter PNG compression level (0-9); leave empty for default (4) | |
| set /p "P_VAL=Value: %ESC%[91m" | |
| if "%P_VAL%"=="" set "P_VAL=4" | |
| set "FORMAT=PNG" | |
| set "EXT=png" | |
| set "F_OPTS=-define png:compression-level=%P_VAL%" | |
| set "F_DISP=PNG c%P_VAL%" | |
| goto MAIN_MENU | |
| :SET_JPG | |
| cls | |
| echo Enter JPEG quality (1-100); leave empty for default (80) | |
| set /p "J_VAL=Value: %ESC%[91m" | |
| if "%J_VAL%"=="" set "J_VAL=80" | |
| echo %ESC%[0m | |
| set "FORMAT=JPEG" | |
| set "EXT=jpg" | |
| set "F_OPTS=-quality %J_VAL%" | |
| set "F_DISP=JPEG q%J_VAL%" | |
| goto MAIN_MENU | |
| :SET_TIF | |
| qmenu -t "Select TIFF Compression" -c "None,BZip,Fax,Group4,JPEG,JPEG2000,Lossless,LZW,RLE,Zip" | |
| set "C_CHOICE=%ERRORLEVEL%" | |
| set "FORMAT=TIF" | |
| set "EXT=tif" | |
| if %C_CHOICE%==1 set "T_TYPE=None" | |
| if %C_CHOICE%==2 set "T_TYPE=BZip" | |
| if %C_CHOICE%==3 set "T_TYPE=Fax" | |
| if %C_CHOICE%==4 set "T_TYPE=Group4" | |
| if %C_CHOICE%==5 set "T_TYPE=JPEG" | |
| if %C_CHOICE%==6 set "T_TYPE=JPEG2000" | |
| if %C_CHOICE%==7 set "T_TYPE=Lossless" | |
| if %C_CHOICE%==8 set "T_TYPE=LZW" | |
| if %C_CHOICE%==9 set "T_TYPE=RLE" | |
| if %C_CHOICE%==10 set "T_TYPE=Zip" | |
| set "F_OPTS=-compress %T_TYPE%" | |
| set "F_DISP=TIF-%T_TYPE%" | |
| goto MAIN_MENU | |
| :SET_RESIZE | |
| cls | |
| echo ╔═══════════════════════════════════════════════════════════╗ | |
| echo ║ %ESC%[92mInput tiles scaling%ESC%[0m ║ | |
| echo ╠═════════════════════╦═════════════════════════════════════╣ | |
| echo ║ Syntax ║ Effect ║ | |
| echo ╠═════════════════════╬═════════════════════════════════════╣ | |
| echo ║ %ESC%[97m50%%%%%ESC%[0m ║ %ESC%[91m50%%%ESC%[0m of original size (default) ║ | |
| echo ║ %ESC%[97m1200%ESC%[0m ║ max width %ESC%[91m1200px%ESC%[0m (keep ratio) ║ | |
| echo ║ %ESC%[97mx800%ESC%[0m ║ max height %ESC%[91m800px%ESC%[0m (keep ratio) ║ | |
| echo ║ %ESC%[97m800x600^^!%ESC%[0m ║ force %ESC%[91m800x600px%ESC%[0m (ignore ratio) ║ | |
| echo ║ %ESC%[97m1024x768^>%ESC%[0m ║ resize only if larger than %ESC%[91mlimits%ESC%[0m ║ | |
| echo ║ %ESC%[97m50000@%ESC%[0m ║ resize to max %ESC%[91m50000 pixels%ESC%[0m (area) ║ | |
| echo ╠═════════════════════╩═════════════════════════════════════╣ | |
| echo ║ Resizes size of original images not the result. See more: ║ | |
| echo ╠═════%ESC%[96mhttps://legacy.imagemagick.org/Usage/resize/#resize%ESC%[0m═══╣ | |
| echo ╚═══════════════════════════════════════════════════════════╝ | |
| set /p "R_VAL=Enter resize value: %ESC%[91m" | |
| echo %ESC%[0m | |
| set "RESIZE=%R_VAL%" | |
| goto MAIN_MENU | |
| :SET_ADDITIONAL | |
| cls | |
| echo ╔═════════════════════════════════════════════════════════╗ | |
| echo ║ %ESC%[92mQuick examples for additional commands%ESC%[0m ║ | |
| echo ╠═══════════════════╦═════════════════════════════════════╣ | |
| echo ║ Command ║ Effect ║ | |
| echo ╠═══════════════════╬═════════════════════════════════════╣ | |
| echo ║ %ESC%[97m-background%ESC%[0m %ESC%[91mcolor%ESC%[0m ║ sets frame color to %ESC%[91mcolor%ESC%[0m ║ | |
| echo ║ %ESC%[97m-shadow%ESC%[0m ║ adds shadow to tiles ║ | |
| echo ║ %ESC%[97m-label "%%%%t"%ESC%[0m ║ adds filename under image ║ | |
| echo ║ %ESC%[97m-pointsize%ESC%[0m %ESC%[91msize%ESC%[0m ║ sets label font size to %ESC%[91msize%ESC%[0m ║ | |
| echo ║ %ESC%[97m-polaroid%ESC%[0m %ESC%[91mangle%ESC%[0m ║ polaroid-like with %ESC%[91mangle%ESC%[0m rotation ║ | |
| echo ║ %ESC%[97m-title "title"%ESC%[0m ║ adds %ESC%[91mtitle%ESC%[0m at the top ║ | |
| echo ╠═══════════════════╩═════════════════════════════════════╣ | |
| echo ║ See more: ║ | |
| echo ╠═════════%ESC%[96mhttps://imagemagick.org/montage/#options%ESC%[0m════════╣ | |
| echo ╚═════════════════════════════════════════════════════════╝ | |
| echo. | |
| echo Current: %ADD_CMD% | |
| set /p "ADD_CMD=Enter extra arguments: %ESC%[91m" | |
| echo %ESC%[0m | |
| goto MAIN_MENU | |
| :RUN_MAGICK | |
| cls | |
| echo. | |
| echo Generating using command line: | |
| echo magick montage -monitor !ADD_CMD! %* -tile %TILES% -geometry +%BORDER%+%BORDER% -resize !RESIZE! %F_OPTS% "%OUT_DIR%tiles_%RANDOM%.%EXT%" | |
| magick montage -monitor !ADD_CMD! %* -tile %TILES% -geometry +%BORDER%+%BORDER% -resize !RESIZE! %F_OPTS% "%OUT_DIR%tiles_%RANDOM%.%EXT%" | |
| if %ERRORLEVEL% EQU 0 ( | |
| echo Success. | |
| ) else ( | |
| echo ImageMagick Error. | |
| pause | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment