Last active
December 1, 2018 15:20
-
-
Save tenforward/20aa514837814ec379ac9076f18ed9ca to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# script for me | |
usage() { | |
echo "usage: $(basename $0) [options...]" >&2 | |
} | |
help() { | |
echo >&2 | |
usage | |
echo >&2 | |
echo "Convert and insert credit to images" | |
echo " -i / --iphone iPhone" | |
echo " -x / --xperia Xperia X (F5121)" | |
echo " -c / --casio Casio compact digital camera" | |
echo " -e / --essential Essential Phone" | |
echo " -o / --opencamera OpenCamera (Essential Phone)" | |
echo " -f / --font Font name" | |
echo " -h / --help show this help." | |
} | |
TYPE="NONE" | |
FONT="Noto Sans" | |
lopts="iphone,xperia,casio,essential,help,font:,opencamera" | |
sopts="ixcehof:" | |
if ! options=`getopt -o $sopts -l $lopts -- "$@"`; then | |
usage | |
exit 1 | |
fi | |
eval set -- "$options" | |
while true; do | |
case "$1" in | |
-i|--iphone) TYPE="IPHONE" ; shift 1 ;; | |
-x|--xperia) TYPE="XPERIA" ; shift 1 ;; | |
-c|--casio) TYPE="CASIO" ; shift 1 ;; | |
-e|--essential) TYPE="ESSENTIAL" ; shift 1 ;; | |
-o|--opencamera) TYPE="OPENCAMERA" ; shift 1 ;; | |
-f|--font) FONT="$2" ; shift 2 ;; | |
-h|--help) help ; exit 0 ;; | |
*) break ;; | |
esac | |
done | |
case "$TYPE" in | |
"IPHONE") | |
# for iPhone | |
fontsize="70" | |
annotate="+1300+10" | |
;; | |
"XPERIA") | |
# for Xperia | |
fontsize="80" | |
annotate="+1600+10" | |
# for Xperia 23MP | |
#fontsize=100 | |
#annotate="+2000+10" | |
;; | |
"CASIO") | |
# for casio camera | |
fontsize="60" | |
annotate="+1450+10" | |
;; | |
"ESSENTIAL") | |
fontsize=80 | |
annotate="+1700+10" | |
;; | |
"OPENCAMERA") | |
# for Open Camera on Essential Phone | |
fontsize=60 | |
annotate="+1000+10" | |
;; | |
*) | |
usage | |
;; | |
esac | |
width=1024 | |
gravity="South" | |
label='by @ten_forward' | |
color=ForestGreen | |
mkdir -p conv | |
for f in $(ls *.JPG *.jpg) | |
do | |
echo "* Now convert: $f" | |
convert \ | |
-gravity $gravity \ | |
-font "$FONT" \ | |
-pointsize $fontsize \ | |
-fill $color \ | |
-annotate $annotate "$label" \ | |
-resize ${width}x \ | |
$f conv/$f | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment