Last active
August 29, 2015 14:00
-
-
Save themarcthomas/11404108 to your computer and use it in GitHub Desktop.
ImageMagick Shell Command for Discount Codes
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/sh | |
# | |
# Uses ImageMagick to add text to an image based on Graham Ashton's Gist: https://github.com/gma/moo-card-codes. | |
COLOR="${COLOR:-black}" | |
FONT="${FONT:-Courier-Bold}" | |
FONT_SIZE="${FONT_SIZE:-31}" | |
TEMPLATE="${TEMPLATE:-template.jpg}" | |
TEXT_POSITION_X="${TEXT_POSITION_x:-+450}" | |
TEXT_POSITION_Y="${TEXT_POSITION_Y:-+365}" | |
## Main program | |
[ -n "$DEBUG" ] && set -x | |
let i=1 | |
read CODE | |
while [ -n "$CODE" ]; do | |
OUTPUT="card-$(printf '%03d' $i).jpg" | |
echo "Creating $OUTPUT with code $CODE" | |
convert $TEMPLATE -pointsize $FONT_SIZE -fill $COLOR -font $FONT -annotate $TEXT_POSITION_X$TEXT_POSITION_Y $CODE $OUTPUT | |
let i=i+1 | |
read CODE | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment