Skip to content

Instantly share code, notes, and snippets.

@ahaxu
Created April 27, 2023 03:27
Show Gist options
  • Save ahaxu/8c36a8cf906f93129bd5fb934adbdf69 to your computer and use it in GitHub Desktop.
Save ahaxu/8c36a8cf906f93129bd5fb934adbdf69 to your computer and use it in GitHub Desktop.
ecert generate
#!/bin/bash
set -e
slugify () {
echo "$1" | iconv -c -t ascii//TRANSLIT | sed -E 's/[~^]+//g' | sed -E 's/[^a-zA-Z0-9]+/-/g' | sed -E 's/^-+|-+$//g' | tr A-Z a-z
}
NAME=$1
DISTANCE=$2
LOOPS=$3
TOTAL_TIME=$4
UNAME=$(echo "$NAME" | awk '{print toupper($0)}')
SOURCE_BG="./htmt-ecert-bg.jpeg"
OUTPUT=`slugify "$NAME"`
echo $UNAME
echo "wrote file to $OUTPUT.jpg"
convert -font "iosevka-bold" \
-fill black -pointsize 130 -gravity center \
-draw "text 0,-300 '$UNAME'" \
$SOURCE_BG "$OUTPUT-1.jpg"
convert -font "chalkboard" \
-fill black -pointsize 90 -gravity center \
-draw "text 0,-150 'DISTANCE: $DISTANCE KM" \
"$OUTPUT-1.jpg" "$OUTPUT-2.jpg"
convert -font "chalkboard" \
-fill black -pointsize 90 -gravity center \
-draw "text 0,0 'LOOPS: $LOOPS" \
-draw "text 0,150 'TOTAL TIME: $TOTAL_TIME" \
"$OUTPUT-2.jpg" "$OUTPUT-cert.jpg"
@ahaxu
Copy link
Author

ahaxu commented Apr 27, 2023

Run with

# $1 is ath name
# $2 is distance
# $3 is loops
# $4 is total time
./ecert.sh "thiết bình" 69.69 23 "9:6:9"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment