-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.cover_image
163 lines (138 loc) · 4.32 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
# Makefile.cover_image
# This file is common to the following
# ne alinome (http://ne.alinome.net) projects:
#
# - Curt grammatica de Interlingue/Occidental
# - Diccionario español-interlingüe
# - English-Interlingue Dictionary
# - Grammatica de Interlingue in Interlingue
# - Interlingue Course in 10 Lessons
# - Li defectes ínacceptabil de Interlingua Gode
# By Marcos Cruz (programandala.net)
# Last modified 20241021T0737+0200.
# 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
# ==============================================================
# Default values {{{1
author_pointsize ?= 72
title_pointsize ?= 128
# ==============================================================
# Create the cover image {{{1
# ------------------------------------------------
# Create the canvas and texts of the cover image {{{2
font=Helvetica
publisher_font=Helvetica
background=yellow
fill=black
strokewidth=4
logo='\#FFD700' # gold
tmp/$(cover).title.png:
convert \
-background transparent \
-fill $(fill) \
-font $(font) \
-pointsize $(title_pointsize) \
-size 1200x \
-gravity east \
caption:$(cover_title) \
$@
tmp/$(cover).author.png:
convert \
-background transparent \
-fill $(fill) \
-font $(font) \
-pointsize $(author_pointsize) \
-size 896x \
-gravity east \
caption:$(cover_author) \
$@
tmp/$(cover).publisher.png:
convert \
-background transparent \
-fill $(fill) \
-font $(publisher_font) \
-pointsize 24 \
-gravity east \
-size 128x \
caption:$(publisher) \
$@
tmp/$(cover).logo.png: img/icon_plaincircle.svg
convert $< \
-fuzz 50% \
-fill $(background) \
-opaque white \
-fuzz 50% \
-fill $(logo) \
-opaque black \
-resize 256% \
$@
tmp/$(cover).decoration.png: img/$(book)_cover_decoration.png
convert $< \
-fuzz 10% \
-fill $(background) \
-opaque white \
-resize 48% \
$@
# ------------------------------------------------
# Create the cover image {{{2
target/$(cover).jpg: \
tmp/$(cover).title.png \
tmp/$(cover).author.png \
tmp/$(cover).publisher.png \
tmp/$(cover).logo.png \
tmp/$(cover).decoration.png
convert -size 1200x1600 canvas:$(background) $@
composite -gravity south -geometry +000+000 tmp/$(cover).logo.png $@ $@
composite -gravity northeast -geometry +048+048 tmp/$(cover).title.png $@ $@
composite -gravity northeast -geometry +048+512 tmp/$(cover).author.png $@ $@
composite -gravity southeast -geometry +048+048 tmp/$(cover).publisher.png $@ $@
composite -gravity west -geometry +102+170 tmp/$(cover).decoration.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/$(cover).pdf: target/$(cover).jpg
img2pdf --output $@ --border 0 $<
# ------------------------------------------------
# Create a thumb version of the cover image {{{2
%_thumb.jpg: %.jpg
convert $< -resize 190x $@
# ==============================================================
# Change log {{{1
# 2020-02-24: Prepare a cover image of "Grammatica de Interlingue in
# Interlingue".
#
# 2020-04-01: Improve the cover image for "Grammatica de Interlingue in
# Interlingue".
#
# 2020-04-01: Add a cover image to "Grammatica de Interlingue in Interlingue".
#
# 2020-04-01: Add the decoration to the cover image of "Grammatica de
# Interlingue in Interlingue".
#
# 2020-04-02: Add a cover image to "Interlingue Course in 10 Lessons".
#
# 2020-04-06: Adjust the size and layout of the cover texts for "Grammatica de
# Interlingue in Interlingue" and "Interlingue Course in 10 Lessons".
#
# 2020-08-24: Add a cover image to "English-Interlingue Dictionary".
#
# 2020-08-28: Extract the cover image Makefile code common to the three
# projects, in order to share it and make updates easier.
#
# 2020-11-03: Document the requirements.
#
# 2020-11-04: Add a variable for the publisher font. This makes the code easier
# to reuse in other projects.
#
# 2021-04-29: Update file header.
#
# 2021-04-30: Make the title and author sizes configurable, keeping their
# default values.
#
# 2024-10-21: Update file header.