-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcover_generator.sh
More file actions
45 lines (35 loc) · 858 Bytes
/
cover_generator.sh
File metadata and controls
45 lines (35 loc) · 858 Bytes
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
#!/usr/bin/bash
# sh cover_generator.sh -t 女仙外史 -a 吕熊
usage() {
echo "Usage: $0 \
[-t title] \
[-a author]" 1>&2
exit 1
}
while getopts ":t:a:" option; do
case "${option}" in
t) title=${OPTARG} ;;
a) author=${OPTARG} ;;
esac
done
if [[ ! "$title" ]]; then
usage
fi
shopt -s extglob
verticalize() {
local tmp=${1}
echo ${tmp//@()/\\n}
}
title_formatted=$(verticalize $title)
author_formatted=$(verticalize $author)\\n著
books_dir=$(cat books_dir)
extension=png
dir="$books_dir/$extension"
mkdir -p $dir
file=$dir/$title.$extension
echo "magick $file"
magick cover_template.png \
-resize 430 \
-font 'fonts/simsun.ttf' -fill '#312819' -pointsize 36 -gravity North -annotate +128+70 $title_formatted \
-font 'fonts/stfangso.ttf' -fill '#312819' -pointsize 18 -gravity North -annotate +128+340 $author_formatted \
$file