Last active 1731167793

forum_sig.cron.sh Raw
1#!/bin/sh
2# generate forum signatures for black and white backgrounds
3# files get optimized with optipng, advpng and pngcrush
4# you may want to install them; if you don't have them installed
5# the output files get not optimized
6# for random output I utilize a perl script `randomquote.pl` which
7# is not my own and the author does not want it to be re-distributed
8# so you might want to find something that suits your need
9#
10# Author: Dominic Reich <quick.hat4396@qtztsjosmprqmgtunjyf.com>
11# Last modified: 2024-01-15 02:36
12#
13
14# font_path=/usr/local/share/fonts/spleen/
15font_path=/usr/share/fonts/spleen
16# files create in actual dir _dark.png and _light.png are added to filename
17file_prefix=forumsig
18quote=$(~/bin/randomquote.pl | fold -sw 76)
19
20# dark
21convert -background black -fill \#ddd -font ${font_path}/spleen-32x64.otf \
22 -antialias -pointsize 20 label:"$quote" ${file_prefix}_dark.png
23
24# light
25convert -background white -fill \#222 -font ${font_path}/spleen-32x64.otf \
26 -antialias -pointsize 20 label:"$quote" ${file_prefix}_light.png
27
28missing=""
29
30command -v optipng > /dev/null 2>&1 || { missing="$missing optiping"; }
31command -v advpng > /dev/null 2>&1 || { missing="$missing advpng"; }
32command -v pngcrush > /dev/null 2>&1 || { missing="$missing pngcrush"; }
33
34if [ -n "$missing" ]
35then
36 echo >&2 "could not find:$missing"
37 exit 1
38fi
39
40for file in ${file_prefix}_{dark,light}.png
41do
42 optipng -nb -nc $file > /dev/null 2>&1
43 advpng -z4 $file > /dev/null 2>&1
44 pngcrush -rem gAMA -rem alla -rem cHRM -rem iCCP -rem sRGB -rem time -ow $file > /dev/null 2>&1
45done
46