blob: dc974f566ed4623140fbb577c64612524542aa09 (
plain) (
blame)
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
#!/bin/sh -e
HERE=$(dirname $(readlink -f ${0}));
cd ${HERE};
rm -f gen_*;
#---------------------------------------------------------------
# Transparent monochrome (B on W, W on B) SVGs from master.
##
# Target: color
#
# Optionally apply color transformations here.
#
cp polyguin.svg gen_polyguin_color.svg
##
# Target: black
#
# Convert color SVG to black SVG and maintain transparency.
#
cp polyguin.svg gen_polyguin_black.svg
grep fill: polyguin.svg \
| grep -v fill:none \
| grep -E -o '\#[a-f0-9]*\w' \
| sort \
| uniq \
| cut -d\# -f2 \
| while read k; do
sed -i gen_polyguin_black.svg \
-e 's@'"$k"'@__BLACK_'"$k"'__@g' \
;
done \
;
grep fill: polyguin.svg \
| grep -v fill:none \
| grep -E -o '\#[a-f0-9]*\w' \
| sort \
| uniq \
| cut -d\# -f2 \
| sed 's/.\{2\}/& /g' \
| awk '{ print "0x"$1,"0x"$2,"0x"$3, ($1 $2 $3) }' \
| awk --non-decimal-data '{ print $4, (1 - (($1 + $2 + $3) / (3 * 256))) }' \
| while read a b; do
sed -i gen_polyguin_black.svg \
-e '/'"$a"'/ s@-opacity:1@-opacity:'"$b"'@g' \
-e '/'"$a"'/ s@__BLACK_[a-f0-9]*__@000000@g' \
;
done \
;
##
# Target: white
#
# Convert color SVG to white SVG and maintain transparency.
#
cp polyguin.svg gen_polyguin_white.svg
grep fill: polyguin.svg \
| grep -v fill:none \
| grep -E -o '\#[a-f0-9]*\w' \
| sort \
| uniq \
| cut -d\# -f2 \
| while read k; do
sed -i gen_polyguin_white.svg \
-e 's@'"$k"'@__WHITE_'"$k"'__@g' \
;
done \
;
grep fill: polyguin.svg \
| grep -v fill:none \
| grep -E -o '\#[a-f0-9]*\w' \
| sort \
| uniq \
| cut -d\# -f2 \
| sed 's/.\{2\}/& /g' \
| awk '{ print "0x"$1,"0x"$2,"0x"$3, ($1 $2 $3) }' \
| awk --non-decimal-data '{ print $4, (($1 + $2 + $3) / (3 * 256)) }' \
| while read a b; do
sed -i gen_polyguin_white.svg \
-e '/'"$a"'/ s@-opacity:1@-opacity:'"$b"'@g' \
-e '/'"$a"'/ s@__WHITE_[a-f0-9]*__@ffffff@g' \
;
done \
;
#===============================================================
docker run -v$(pwd):/x -w/x --rm -i alpine:3.17 <<'EOF'
apk add graphicsmagick imagemagick;
#===============================================================
#---------------------------------------------------------------
# SVG master --> scaled PNGs for composition onto logo template.
##
# SVG --> PNG for master logo icon.
#
# x28 is GitLab
# x54 is Website
# x200 is SPI project page
# x900 is WordPress theme
#
# This runs inside Docker because of ImageMagick bugs and GM is
# the only free software I can find that doesn't screw this up.
#
for c in color black white; do
for r in x28 x54 x200 x900; do
gm convert -trim -density 600 -resize ${r} -background none gen_polyguin_${c}.svg gen_polyguin_${c}_${r}.png;
magick convert -auto-level -brightness-contrast -5x+25 gen_polyguin_${c}_${r}.png gen_polyguin_${c}_${r}.png;
chown 1000:1000 gen_polyguin_${c}_${r}.png;
done # r
done # c
#---------------------------------------------------------------
# PSD master --> scaled PNGs for composition onto logo template.
##
# PSD --> PNG for master logo icon.
#
# x28 is GitLab
# x54 is Website
# x200 is SPI project page
# x900 is WordPress theme
#
# GM does not support PSD anymore!
#
find . -type f -name "*.psd" | cut -d'/' -f2 | while read k; do
for r in x28 x54 x200 x900; do
magick convert -resize ${r} "${k}[0]" "gen_${k%*.psd}_${r}.png";
chown 1000:1000 "gen_${k%*.psd}_${r}.png";
done
done
#---------------------------------------------------------------
# SVG + PSD template composition.
##
# Contrast suffers a bit but these are great on image backgrounds.
#
for c in color black white; do
for r in x28 x54 x200 x900; do
# transparent black polyguin
gm composite gen_polyguin_${c}_${r}.png gen_polylogo_template_black_${r}.png gen_polylogo_black_${c}_${r}.png;
chown 1000:1000 gen_polylogo_black_${c}_${r}.png;
# transparent white polyguin
gm composite gen_polyguin_${c}_${r}.png gen_polylogo_template_white_${r}.png gen_polylogo_white_${c}_${r}.png;
chown 1000:1000 gen_polylogo_white_${c}_${r}.png;
done # r
done # c
##
# These have better contrast and are suited for solid backgrounds.
#
# FIXME: improve contrast.
#
for r in x28 x54 x200 x900; do
# solid black color --> grayscale polyguin
magick convert -colorspace Gray gen_polylogo_black_color_${r}.png gen_polylogo_black_mono_${r}.png;
chown 1000:1000 gen_polylogo_black_mono_${r}.png;
# solid white color --> grayscale polyguin
magick convert -colorspace Gray gen_polylogo_white_color_${r}.png gen_polylogo_white_mono_${r}.png;
chown 1000:1000 gen_polylogo_black_mono_${r}.png;
done # r
#---------------------------------------------------------------
# Favicon generation.
##
# 32x32 is GitLab
# Website uses native SVG
#
magick convert -background none -gravity center -resize 32x32 -extent 32x32 gen_polyguin_color.svg icons/gen_polyguin_color_favicon.ico;
chown 1000:1000 icons/gen_polyguin_color_favicon.ico;
#---------------------------------------------------------------
# Other custom outputs.
##
# GitLab group/project avatar is 96x96 square. MUST be square.
#
magick convert -background none -gravity center -resize 96x96 -extent 96x96 gen_polyguin_color.svg gen_polyguin_color_gitlab.png;
chown 1000:1000 gen_polyguin_color_gitlab.png;
##
# Twitter avatar is 400x400 square. MUST be square.
#
magick convert -background none -gravity center -resize 400x400 -extent 400x400 gen_polyguin_color.svg gen_polyguin_color_twitter.png;
chown 1000:1000 gen_polyguin_color_twitter.png;
##
# WordPress theme screenshot is 1200x900. MUST be this.
#
magick convert -background none -gravity center -resize 1200x900 -extent 1200x900 gen_polylogo_black_color_x900.png gen_polyguin_color_wordpress.png;
chown 1000:1000 gen_polyguin_color_wordpress.png;
##
# GitHub group/project avatar is 500x500 square. MUST be square.
#
magick convert -background none -gravity center -resize 500x500 -extent 500x500 gen_polyguin_color.svg gen_polyguin_color_github.png;
chown 1000:1000 gen_polyguin_color_github.png;
#===============================================================
EOF
#===============================================================
|