raz / site / assets / render.sh

23 lines · 1.0 KiB · executable · raw · history · last change f938aed4

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.
6set -e
7cd "$(dirname "$0")"
8C=${CHROME:-chromium}
9shot() { # 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}
13icon() { # 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}
18icon logo.svg apple-touch-icon.png 180
19# iOS rounds the corners itself and wants none transparent
20convert apple-touch-icon.png -background "#E07A5F" -alpha remove -alpha off apple-touch-icon.png
21icon favicon.svg favicon-32.png 32
22rm -f .tile.html .big.png
23shot social.png 1200 630 social.html