#!/bin/bash
#-----------------------------------------------------------------------------
# With this bash script your can store any data (text or binary) as a long
# image of qrcodes. Thanks to codegroup, the data is converted to ascii
# letter-only groups of 5 characters. It is then split and converted to
# qrcodes, which are then combined into one image.
#
# You could, of course, encrypt the data before storing it as well.
#
# You'll need bash, gzip, parallel, zbar-tools, codegroup, and imagemagick
# sudo apt-get install bash imagemagick gzip parallel zbar-tools codegroup
#
# Put this script in its own working directory/folder!
# Copy the data file to the working folder.
# Do not run this script on your only copy of some data!
#
# Use the script:
# $ ./qrcg.sh "Filename"
#-----------------------------------------------------------------------------
COUNTER=0
IFS=$'\n'
# Begin for ldata loop
for ldata in $( cat $1 |gzip -9 | codegroup | parallel --no-notice -N60 echo)
do
let COUNTER+=1
echo "Working on QRcode $COUNTER"
PADCOUNT=$(printf "%08d" $COUNTER)
qrencode -m 8 -o $PADCOUNT.png "$ldata"
convert $PADCOUNT.png -gravity South -pointsize 15 -annotate +0+0 "$(basename $1) $PADCOUNT" $PADCOUNT.png
done
# End for ldata loop
#
# Comment out the following two lines if you just want
# a collection of qrcodes in separate pngs
convert *.png -append inline.png
rm 00*.png
#-----------------------------------------------------------------------------
# To restore file from qrcodes:
# $ zbarimg -q --raw -Sdisable -Sqrcode.enable inline.png | sed 's/[0-9]*//g' | tac |codegroup -d |gzip -d > out.file
#-----------------------------------------------------------------------------
Comments