-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.cover_image
101 lines (78 loc) · 2.36 KB
/
Makefile.cover_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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Makefile.cover_image
# This file is part of Sin Forth
# http://programandala.net/en.program.sin_forth.html
# By Marcos Cruz (programandala.net)
# Last modified 202012111908
# See change log at the end of the file
# ==============================================================
# Requirements {{{1
# ImageMagick (by ImageMagick Studio LCC)
# http://imagemagick.org
# img2pdf (by Johannes 'josch' Schauer)
# https://gitlab.mister-muffin.de/josch/img2pdf
# ==============================================================
# Create the cover image {{{1
# ------------------------------------------------
# Create the canvas and texts of the cover image {{{2
font=Helvetica
background=lightgray
fill=black
strokewidth=4
subtitle_pointsize=48
tmp/$(cover).title.png:
convert \
-background transparent \
-fill $(fill) \
-font $(font) \
-pointsize 96 \
-size 1200x \
-gravity east \
caption:$(cover_title) \
$@
tmp/$(cover).subtitle.png:
convert \
-background transparent \
-fill $(fill) \
-font $(font) \
-pointsize $(subtitle_pointsize) \
-size 1200x \
-gravity east \
caption:$(cover_subtitle) \
$@
tmp/$(cover).author.png:
convert \
-background transparent \
-fill $(fill) \
-font $(font) \
-pointsize 48 \
-size 896x \
-gravity east \
caption:$(cover_author) \
$@
# ------------------------------------------------
# Create the cover image {{{2
.PHONY: cover
cover: doc/$(cover).jpg
doc/$(cover).jpg: \
tmp/$(cover).title.png \
tmp/$(cover).subtitle.png \
tmp/$(cover).author.png
convert -size 1200x1600 canvas:$(background) $@
composite -gravity east -geometry +048+000 tmp/$(cover).title.png $@ $@
composite -gravity east -geometry +048+072 tmp/$(cover).subtitle.png $@ $@
composite -gravity east -geometry +048+256 tmp/$(cover).author.png $@ $@
# ------------------------------------------------
# Convert the cover image to PDF {{{2
# This is needed in order to make sure the cover image ocuppies the whole page
# in the PDF versions of the book.
tmp/%.pdf: doc/%.jpg
img2pdf --output $@ --border 0 $<
# ------------------------------------------------
# Create a thumb version of the cover image {{{2
.PHONY: thumb
thumb: doc/$(cover)_thumb.jpg
%_thumb.jpg: %.jpg
convert $< -resize 190x $@
# ==============================================================
# Change log {{{1
# 2020-12-11: Start. Adapt the code from Solo Forth.