Created
June 22, 2022 13:43
-
-
Save marius-m/3f898dac09c40bb1c6514ab85e800389 to your computer and use it in GitHub Desktop.
Bash - QRCode generator
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
#!/bin/bash | |
#set -x | |
OUT_NAME=qrencode-$(uuidgen) | |
OUT_FILEEXT=png | |
OUT_FILENAME=${OUT_NAME}.${OUT_FILEEXT} | |
OUT_FILENAME_TXT=${OUT_NAME}-txt.${OUT_FILEEXT} | |
OUT=/tmp/${OUT_FILENAME} | |
OUT_TXT=/tmp/${OUT_FILENAME_TXT} | |
INPUT=$1 | |
if [[ $# -eq 0 ]] ; then | |
echo "Paste in QR to generate" | |
exit 1 | |
fi | |
echo "-- Generating QR..." | |
echo "$INPUT" | qrencode -t PNG -s 5 -o $OUT | |
LAST_CMD_STATUS=$? | |
if [[ $LAST_CMD_STATUS -ne 0 ]] ; then | |
echo "Error: Could not generate QR code: ${LAST_CMD_STATUS}" | |
exit $LAST_CMD_STATUS | |
fi | |
convert $OUT -gravity South -pointsize 10 -annotate +0+0 "$INPUT" $OUT_TXT | |
open $OUT_TXT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment