-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile.cover_image
191 lines (159 loc) · 5.47 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# Makefile.cover_image
# This file is part of Solo Forth
# http://programandala.net/en.program.solo_forth.html
# By Marcos Cruz (programandala.net)
# Last modified: 202101071859.
# 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
# ==============================================================
# Config {{{1
width=1200
height=1600
size=$(width)x$(height)
margin=+048
title_y=-384
subtitle_y=-312
author_y=-128
font=Helvetica
background=lightgray
fill=black
strokewidth=4
subtitle_pointsize=48
# ==============================================================
# Create the canvas {{{1
tmp/$(cover).title.png:
convert \
-background transparent \
-fill $(fill) \
-font $(font) \
-pointsize 96 \
-size $(width)x \
-gravity east \
caption:$(cover_title) \
$@
# ==============================================================
# Create the texts {{{1
tmp/$(cover).gplusdos_subtitle.png:
convert \
-background transparent \
-fill $(fill) \
-font $(font) \
-pointsize $(subtitle_pointsize) \
-size 1200x \
-gravity east \
caption:$(cover_gplusdos_subtitle) \
$@
tmp/$(cover).nextzxos_subtitle.png:
convert \
-background transparent \
-fill $(fill) \
-font $(font) \
-pointsize $(subtitle_pointsize) \
-size 1200x \
-gravity east \
caption:$(cover_nextzxos_subtitle) \
$@
tmp/$(cover).plus3dos_subtitle.png:
convert \
-background transparent \
-fill $(fill) \
-font $(font) \
-pointsize $(subtitle_pointsize) \
-size 1200x \
-gravity east \
caption:$(cover_plus3dos_subtitle) \
$@
tmp/$(cover).trdos_subtitle.png:
convert \
-background transparent \
-fill $(fill) \
-font $(font) \
-pointsize $(subtitle_pointsize) \
-size 1200x \
-gravity east \
caption:$(cover_trdos_subtitle) \
$@
tmp/$(cover).author.png:
convert \
-background transparent \
-fill $(fill) \
-font $(font) \
-pointsize 48 \
-size 896x \
-gravity east \
caption:$(cover_author) \
$@
# ==============================================================
# Convert the background of the current release {{{1
tmp/$(cover).background.png: backgrounds/current.pbm
convert \
$< \
-fuzz 4% -transparent "#ffffff" \
-resize $(width)x \
$@
# ==============================================================
# Create the cover image {{{1
doc/gplusdos_$(cover).jpg: \
tmp/$(cover).title.png \
tmp/$(cover).gplusdos_subtitle.png \
tmp/$(cover).background.png \
tmp/$(cover).author.png
convert -size $(size) canvas:$(background) $@
composite -gravity east -geometry $(margin)$(title_y) tmp/$(cover).title.png $@ $@
composite -gravity east -geometry $(margin)$(subtitle_y) tmp/$(cover).gplusdos_subtitle.png $@ $@
composite -gravity east -geometry $(margin)$(author_y) tmp/$(cover).author.png $@ $@
composite -gravity southeast -geometry $(margin)$(margin) tmp/$(cover).background.png $@ $@
doc/nextzxos_$(cover).jpg: \
tmp/$(cover).title.png \
tmp/$(cover).nextzxos_subtitle.png \
tmp/$(cover).background.png \
tmp/$(cover).author.png
convert -size $(size) canvas:$(background) $@
composite -gravity east -geometry $(margin)$(title_y) tmp/$(cover).title.png $@ $@
composite -gravity east -geometry $(margin)$(subtitle_y) tmp/$(cover).nextzxos_subtitle.png $@ $@
composite -gravity east -geometry $(margin)$(author_y) tmp/$(cover).author.png $@ $@
composite -gravity southeast -geometry $(margin)$(margin) tmp/$(cover).background.png $@ $@
doc/plus3dos_$(cover).jpg: \
tmp/$(cover).title.png \
tmp/$(cover).plus3dos_subtitle.png \
tmp/$(cover).background.png \
tmp/$(cover).author.png
convert -size $(size) canvas:$(background) $@
composite -gravity east -geometry $(margin)$(title_y) tmp/$(cover).title.png $@ $@
composite -gravity east -geometry $(margin)$(subtitle_y) tmp/$(cover).plus3dos_subtitle.png $@ $@
composite -gravity east -geometry $(margin)$(author_y) tmp/$(cover).author.png $@ $@
composite -gravity southeast -geometry $(margin)$(margin) tmp/$(cover).background.png $@ $@
doc/trdos_$(cover).jpg: \
tmp/$(cover).title.png \
tmp/$(cover).trdos_subtitle.png \
tmp/$(cover).background.png \
tmp/$(cover).author.png
convert -size $(size) canvas:$(background) $@
composite -gravity east -geometry $(margin)$(title_y) tmp/$(cover).title.png $@ $@
composite -gravity east -geometry $(margin)$(subtitle_y) tmp/$(cover).trdos_subtitle.png $@ $@
composite -gravity east -geometry $(margin)$(author_y) tmp/$(cover).author.png $@ $@
composite -gravity southeast -geometry $(margin)$(margin) tmp/$(cover).background.png $@ $@
# ==============================================================
# Convert the cover image to PDF {{{1
# 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 {{{1
%_thumb.jpg: %.jpg
convert $< -resize 190x $@
# ==============================================================
# Change log {{{1
# 2020-10-08: Start. Adapt the code from other projects of the author.
#
# 2020-12-11: Add the list of requirements.
#
# 2021-01-07: Add the rules to make the NextZXOS cover image. Add the Solo
# Forth background image to the cover image. Use variables to set the positions
# and sizes. Improve the layout.