Created
January 9, 2015 08:39
-
-
Save NewProggie/786728e27d27a9746f9f to your computer and use it in GitHub Desktop.
Create qr codes with consecutive numbering and labels
This file contains 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
#!/usr/bin/env bash | |
NUM_QR_CODES=80 | |
DPI=300 | |
TMP_DIR=qrtemp | |
W_GRID=$(echo "scale=0; sqrt(${NUM_QR_CODES}/sqrt(2))" | bc -l) | |
H_GRID=$(echo "scale=0; ${NUM_QR_CODES}/${W_GRID}" | bc -l) | |
# install dependencies | |
sudo apt-get -y install qrencode imagemagick | |
# create qr codes and add label | |
mkdir -p ${TMP_DIR} | |
for i in `seq 1 ${NUM_QR_CODES}`; do | |
CURR_NUM=`printf "%.8d" $i` | |
qrencode -l H -o ${TMP_DIR}/${CURR_NUM}.png -d ${DPI} -t png ${CURR_NUM} | |
convert ${TMP_DIR}/${CURR_NUM}.png label:"${CURR_NUM}" -gravity south -append ${TMP_DIR}/${CURR_NUM}.png | |
done | |
# align all qr codes gridwise on A4 paper | |
montage ${TMP_DIR}/*.png -tile ${W_GRID}x${H_GRID} qrcodes.pdf | |
# clean up | |
for i in `seq 1 ${NUM_QR_CODES}`; do | |
CURR_NUM=`printf "%.8d" $i` | |
rm -f ${TMP_DIR}/${CURR_NUM}.png | |
done | |
rm -rf ${TMP_DIR} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment