Skip to content

Instantly share code, notes, and snippets.

@diegogurpegui
Created February 27, 2021 22:34
Show Gist options
  • Save diegogurpegui/34c079247af8a9c89ea132146fb59299 to your computer and use it in GitHub Desktop.
Save diegogurpegui/34c079247af8a9c89ea132146fb59299 to your computer and use it in GitHub Desktop.
Export file to QR images (in 2kb parts)
#!/bin/bash
############################################################################
# Export a file to several QR files
#
# Requirements:
# - qrencode (https://github.com/fukuchi/libqrencode)
#
# How to use
# $ export_file_qr.sh name.of.your.file
############################################################################
# Get args
sourceFile=$1
# Split in files
split -b 2048 $sourceFile ${sourceFile}_
# Iterate over each file and convert to QR
fileParts=(./${sourceFile}_[abcdef]*)
i=0
for fileNamePart in "${fileParts[@]}"
do
newQRFileName=${sourceFile}-${i}.png
qrencode --size 6 --dpi 72 -o ${newQRFileName} < $fileNamePart
echo "Generated QR file: $newQRFileName"
((i=i+1))
done
# now delete the "part" files
rm ${sourceFile}_[abcdef]*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment