Skip to content

Instantly share code, notes, and snippets.

@PatHightree
Created September 4, 2024 09:45
Show Gist options
  • Save PatHightree/dfd724a2f81ea82eefc6cb87cec787c6 to your computer and use it in GitHub Desktop.
Save PatHightree/dfd724a2f81ea82eefc6cb87cec787c6 to your computer and use it in GitHub Desktop.
Image magick script which takes all tif images in a folder and assembles them in a grid
@echo off
setlocal enabledelayedexpansion
REM Set the directory containing the images
set "img_dir=D:\Projects\- Looking Glass Portrait\MIOPS Capsule Slider\Render\Cicada_01"
set "output_file=%img_dir%\collage.jpg"
REM Create a sorted list of images
set "sorted_list="
for /f "tokens=*" %%f in ('dir /b /on "%img_dir%\*.tif"') do (
REM Crop the image to a 9:16 ratio using the rightmost side
magick "%img_dir%\%%f" -gravity East -crop 9:16 +repage "%img_dir%\cropped_%%~nf.tif"
set "sorted_list=!sorted_list! "%img_dir%\cropped_%%~nf.tif""
)
REM Create a grid collage using ImageMagick
REM Adjust the -geometry parameter to set the size of each image in the grid
magick montage !sorted_list! -tile 5x -geometry +0+0 "%output_file%"
REM Clean up cropped images (doesn't work)
del %img_dir%\cropped_*.*
echo Collage created successfully: %output_file%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment