Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@carlynorama
Last active May 30, 2018 16:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlynorama/189e0dc4ebc8624d82a5 to your computer and use it in GitHub Desktop.
Save carlynorama/189e0dc4ebc8624d82a5 to your computer and use it in GitHub Desktop.
Making place holder tiles for a montage
#!/bin/bash
#Creates blank white tiles for a 16x8 grid
#white, 1204x864 unless otherwise specified.
#Using hex colors requires quotes. ie. "#F0F0F0"
#REQUIRES IMAGEMAGICK.
#the first parameter passed to the shell script
#will be the width of the grid needing tiles
WIDTH=$1;
#the second parameter passed to the shell script
#will be the height of the grid needing tiles
HEIGHT=$2;
#the third parameter passed to the shell script
#will be the height of the grid needing tiles
#can take any format imagemagick can.
COLOR=$3;
#the tiles will be put in a directory called...
MYDIR="blank_tiles"
#the file type of the output will be...
EXT="png"
#The zero padding in the name will be up to X characters
#zpad=2
#if the caller of this script fails to input
#values, what should the defaults be?
if [[ -z $WIDTH ]]; then WIDTH=1204 ; fi
if [[ -z $HEIGHT ]]; then HEIGHT=864 ; fi
if [[ -z $COLOR ]]; then COLOR=white ; fi
#If the destination folder doesn't exist, make it.
if [ ! -d ./${MYDIR} ]; then mkdir ./${MYDIR}; fi
#for the rows
for i in {0..7}; do
#do each column
for j in {0..15}; do
#create a column-row coordinate name with the color for each tile.
printf -v filename "%0*dy%0*dx_%s" $zpad $i $zpad $j $COLOR;
#add the directory and the extension (seperate from above for
#troubleshooting reasons)
fullname=./${MYDIR}/${filename}.${EXT};
#do the Imagemagick!
convert -size ${WIDTH}x${HEIGHT} xc:${COLOR} ${fullname}
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment