]> de.git.xonotic.org Git - xonotic/mediasource.git/blob - gfx/crosshairs/luma/render.sh
Render Luma crosshairs with Inkscape to avoid rsvg inconsistencies
[xonotic/mediasource.git] / gfx / crosshairs / luma / render.sh
1 #!/bin/bash
2 set -e
3
4 # Task:
5 #   Render SVG files from ./path/file.svg to OUTDIR/path/file.tga
6 #   Overwrites existing tga files.
7 #
8 # Usage:
9 #   ./render.sh OUTDIR SVG...
10 #
11 # Examples:
12 #   One file:  ./render.sh ~/.xonotic/data gfx/crosshair64.svg
13 #   All files: ./render.sh ~/.xonotic/data $(find . -name "*.svg")
14 #
15 # Dependencies:
16 #   Inkscape (1.0.1)
17 #   ImageMagick (7.0.7)
18
19 outDir="$1"; shift
20
21 for svg in "$@"; do
22         # Extract name components
23         svgDir=$(dirname -- "$svg")
24         svgName=$(basename -- "$svg" .svg)
25
26         # Compose target file names
27         dir="$outDir/$svgDir"
28         tga="$dir/$svgName.tga"
29         tmp="$dir/$svgName.tmp.png"
30
31         # Ensure target directory exists
32         mkdir --parent "$dir"
33
34         # Render image
35         inkscape --export-filename "$tmp" "$svg"
36         convert -auto-orient "$tmp" -compress RLE "$tga"
37         rm "$tmp"
38 done