-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_label_image
executable file
·54 lines (47 loc) · 1.54 KB
/
create_label_image
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
# by Stefan Ruedisuehli, 2015-08-21
DBG=false
USAGE="usage: $(basename ${0}) <WIDTH> <ANGLE> <DY> <OUTFILE> <LABEL>"
main()
{
# Eval inargs
local narg_exp=5
if [ ${#} -ne ${narg_exp} ]
then
[[ $# -gt 0 ]] && echo "error: wrong arguments (${#}/${narg_exp}): $@" >&2
echo "${USAGE}"
return 1
fi
local width="${1}"
local angle="${2}"
local dy="${3}"
local outfile="${4}"
local label="${5}"
local labelfile="_label.${group}.png"
local size="${width}x$((width/10))"
local pts="$((width*7/100))"
${DBG} && echo "------------------------------"
${DBG} && echo "${0} ${@}"
${DBG} && echo "------------------------------"
${DBG} && echo "label : ${label}"
${DBG} && echo "width : ${width}"
${DBG} && echo "angle : ${angle}"
${DBG} && echo "dy : ${dy}"
${DBG} && echo "outfile : ${outfile}"
${DBG} && echo "------------------------------"
${DBG} && echo "labelfile : ${labelfile}"
${DBG} && echo "size : ${size}"
${DBG} && echo "pts : ${pts}"
${DBG} && echo "------------------------------"
convert -verbose \
-size ${size} \
xc:white \
-fill black \
-font Palatino-Bold \
-pointsize ${pts} \
-gravity center \
-draw "text 0,${dy} '${label}'" \
-rotate ${angle} \
PNG32:"${outfile}"
}
main "${@}"