3 # Render SVGFILEs from path/filename.svg to DATADIR/path/filename.tga,
4 # if they are newer than their target tga file.
7 # To compensate for filter rendering errors and to reduce rbg noise,
8 # the svg files are rendered at a large size and then scaled down.
11 # rsvg-convert (librsvg 2.39.0)
12 # convert (imagemagick 6.8.6-9)
15 # ./render-svg.sh DATADIR [SVGFILE...]
18 # Single file: ./render-svg.sh ~/.xonotic/data gfx/menu/luma/cursor.svg
19 # All files: ./render-svg.sh ~/.xonotic/data $(find . -name "*.svg")
23 if [ -z "$1" ] || [ "${1##*.}" = "svg" ]; then
24 echo "Usage: $0 DATADIR [SVGFILE...]"
37 tga="$data/${svg%.*}.tga"
39 # IF source file has extension .svg AND it exists AND
40 # destination file does NOT exist, OR source file is newer than destination file
41 if [ "$ext" = "svg" ] && [ -f "$svg" ] && [ ! -f "$tga" -o "$svg" -nt "$tga" ]; then
44 w=$(identify -format "%w" "$svg")
45 h=$(identify -format "%h" "$svg")
46 scale=$(echo "s=sqrt($maxPixels/$w/$h);if(s>$maxScale)s=$maxScale;s" | bc)
49 # -auto-orient works around an inversion regression present in imagemagick 6.9.11-60
50 rsvg-convert -z "$scale" "$svg" | convert - -auto-orient -scale "$w" "$tga"
52 printf "NOT rendering source $svg because "
53 if [ ! "$ext" = "svg" ]; then
54 printf "file extension is not \".svg\"\n"
55 elif [ ! -f "$svg" ]; then
56 printf "file not found\n"
58 printf "$svg is not newer than $tga\n"