| 1 | #!/bin/sh |
| 2 | # Makes the PNGs from the SVGs and social.html: run it after changing a logo. |
| 3 | # It needs Chromium (CHROME=/path/to/chrome to say where) and ImageMagick. |
| 4 | # Chromium won't make a window under 500 px, so the icons are drawn |
| 5 | # large and shrunk. |
| 6 | set -e |
| 7 | cd "$(dirname "$0")" |
| 8 | C=${CHROME:-chromium} |
| 9 | shot() { # shot out.png width height page |
| 10 | "$C" --headless --no-sandbox --hide-scrollbars --default-background-color=00000000 \ |
| 11 | --screenshot="$1" --window-size="$2,$3" "file://$PWD/$4" >/dev/null 2>&1 |
| 12 | } |
| 13 | icon() { # icon svg out.png size |
| 14 | printf '<body style="margin:0;background:none"><img src="%s" width="512" height="512" style="display:block">' "$1" > .tile.html |
| 15 | shot .big.png 600 600 .tile.html |
| 16 | convert .big.png -crop 512x512+0+0 +repage -resize "$3x$3" "$2" |
| 17 | } |
| 18 | icon logo.svg apple-touch-icon.png 180 |
| 19 | # iOS rounds the corners itself and wants none transparent |
| 20 | convert apple-touch-icon.png -background "#E07A5F" -alpha remove -alpha off apple-touch-icon.png |
| 21 | icon favicon.svg favicon-32.png 32 |
| 22 | rm -f .tile.html .big.png |
| 23 | shot social.png 1200 630 social.html |