Skip to content

Instantly share code, notes, and snippets.

@Wikinaut
Created March 20, 2016 19:48
Show Gist options
  • Save Wikinaut/56f8bdc42343cf0aae33 to your computer and use it in GitHub Desktop.
Save Wikinaut/56f8bdc42343cf0aae33 to your computer and use it in GitHub Desktop.
Make n x m: create an n x m stripe of an image (Windows version)
@ECHO OFF
REM Windows version
REM call make-nxm <image-filename> rows columms [postfilter-command]
IF (%1)==() GOTO HELP
IF (%2)==() GOTO HELP
IF (%3)==() GOTO HELP
SET POSTFILTER=%~4 %~5 %~6 %~7 %~8 %~9
IF (%4)==() SET POSTFILTER=-gaussian-blur 0.5x0.5
set FILENAME=%1
set ROWS=%2
set COLUMNS=%3
setlocal EnableDelayedExpansion
REM see http://stackoverflow.com/questions/6500217/random-variable-not-changing-in-for-loop-in-windows-batch-file
FOR /L %%R IN (1,1,%COLUMNS%) DO @set Y=!Y! %FILENAME%
FOR /L %%C IN (1,1,%ROWS%) DO @SET Z=!Z! "(" %Y% +append ")"
convert %Z% -append %POSTFILTER% %ROWS%x%COLUMNS%_%FILENAME%
GOTO EOF
:HELP
@ECHO:
@ECHO Create a composed n x m image from a single image
@ECHO:
@ECHO Usage^: make-nxm image-filename rows colums [postfilter-command]
@ECHO: default postfilter: -gaussian-blur 0.5x0.5
@ECHO:
@ECHO Examples^: make-nxm img.png 3 4
@ECHO make-nxm img.png 3 4 -gaussian-blur 0.5x0.5
@ECHO:
@ECHO create output image 3x4_img.png
@ECHO composed of 3 rows and 4 columns of img.png
@ECHO with gaussian blur filter 0.5x0.5 (default filter)
@ECHO:
:EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment