79 lines
3.2 KiB
Bash
Executable File
79 lines
3.2 KiB
Bash
Executable File
#!/bin/bash
|
|
################################################################################
|
|
# Author: Fred (support@qo-op.com)
|
|
# Version: 0.1
|
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
################################################################################
|
|
# INSTALLER convert et qrencode: sudo apt install imagemagick qrencode
|
|
################################################################################
|
|
MY_PATH="`dirname \"$0\"`" # relative
|
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
|
ME="${0##*/}"
|
|
############################################################################################################################################################
|
|
# ${MY_PATH}/G1BILLET_MAKE.sh "nu me ro test" "se cr et" 100 7sn9dKeCNEsHmqm1gMWNREke4YAWtNw8KG1YBSN8CmSh 97968583
|
|
############################################################################
|
|
|
|
NUMERO="$1"
|
|
SECRET="$2"
|
|
MONTANT="$3"
|
|
NOTERIB="$4"
|
|
UNIQID="$5"
|
|
|
|
if [[ "$NUMERO" == "" || "$SECRET" == "" || "$MONTANT" == "" || "$NOTERIB" == "" || "$UNIQID" == "" ]]
|
|
then
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p /tmp/g1billet/$UNIQID
|
|
BILLETNAME=$(echo $NUMERO | sed 's/ /_/g')
|
|
|
|
# Add ${MY_PATH}/images/logo.png (250px)
|
|
composite -compose Over -gravity SouthWest -geometry +50+50 -dissolve 70% "${MY_PATH}/images/logo.png" "${MY_PATH}/images/fond.jpg" "/tmp/${BILLETNAME}.jpg"
|
|
|
|
# Prepare BILLET qrcode verification URL
|
|
qrencode -s 6 -o "/tmp/g1billet/${UNIQID}/${BILLETNAME}.QR.png" "$NOTERIB"
|
|
|
|
# Add verification QRCode
|
|
composite -compose Over -gravity NorthEast -geometry +50+25 "/tmp/g1billet/${UNIQID}/${BILLETNAME}.QR.png" "/tmp/${BILLETNAME}.jpg" "/tmp/${BILLETNAME}.jpg"
|
|
|
|
# Change June logo color
|
|
case "$MONTANT" in
|
|
1)
|
|
convert "${MY_PATH}/images/g1.png" -fuzz 20% -fill grey -opaque '#e5912b' "/tmp/g1billet/g1.png"
|
|
;;
|
|
2)
|
|
convert "${MY_PATH}/images/g1.png" -fuzz 20% -fill green -opaque '#e5912b' "/tmp/g1billet/g1.png"
|
|
;;
|
|
5)
|
|
convert "${MY_PATH}/images/g1.png" -fuzz 20% -fill orange -opaque '#e5912b' "/tmp/g1billet/g1.png"
|
|
;;
|
|
10)
|
|
convert "${MY_PATH}/images/g1.png" -fuzz 20% -fill blue -opaque '#e5912b' "/tmp/g1billet/g1.png"
|
|
;;
|
|
20)
|
|
convert "${MY_PATH}/images/g1.png" -fuzz 20% -fill purple -opaque '#e5912b' "/tmp/g1billet/g1.png"
|
|
;;
|
|
50)
|
|
convert "${MY_PATH}/images/g1.png" -fuzz 20% -fill red -opaque '#e5912b' "/tmp/g1billet/g1.png"
|
|
;;
|
|
100)
|
|
convert "${MY_PATH}/images/g1.png" -fuzz 20% -fill black -opaque '#e5912b' "/tmp/g1billet/g1.png"
|
|
;;
|
|
*)
|
|
cp "${MY_PATH}/images/g1.png" "/tmp/g1billet/g1.png"
|
|
;;
|
|
esac
|
|
|
|
# Add June LOGO to Billet
|
|
composite -compose Over -gravity SouthEast -geometry +20+20 -dissolve 90% "/tmp/g1billet/g1.png" "/tmp/${BILLETNAME}.jpg" "/tmp/${BILLETNAME}.jpg"
|
|
|
|
convert -font 'Liberation-Sans' \
|
|
-pointsize 120 -fill black -draw 'text 250,250 "'"$MONTANT DU"'"' \
|
|
-pointsize 35 -fill black -draw 'text 100,60 "'"G1 BILLET"'"' \
|
|
-pointsize 30 -draw 'text 50,100 "'"Identifiant: $NUMERO"'"' \
|
|
-pointsize 22 -fill black -draw 'text 50,130 "'"Code Secret: $SECRET"'"' \
|
|
-pointsize 22 -fill black -draw 'text 150,440 "'"Porte Monnaie Libre!! Utiliser avec https://cesium.app"'"' \
|
|
"/tmp/${BILLETNAME}.jpg" "/tmp/g1billet/${UNIQID}/${BILLETNAME}.BILLET.jpg"
|
|
|
|
rm -f /tmp/${BILLETNAME}.jpg
|