config/rsvg_convert
changeset 107 6ae203c8b28d
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/config/rsvg_convert	Tue Jun 29 10:08:58 2021 +0100
     1.3 @@ -0,0 +1,74 @@
     1.4 +#!/bin/bash
     1.5 +# A compatibility wrapper for rsvg that makes it act like rsvg-convert
     1.6 +usage()
     1.7 +{
     1.8 +    echo "Usage: rsvg [OPTIONS...] file.svg"
     1.9 +    echo "  -d, --dpi-x=<float>          pixels per inch"
    1.10 +    echo "  -p, --dpi-y=<float>          pixels per inch"
    1.11 +    echo "  -x, --x-zoom=<float>         x zoom factor"
    1.12 +    echo "  -y, --y-zoom=<float>         y zoom factor"
    1.13 +    echo "  -w, --width=<int>            width"
    1.14 +    echo "  -h, --height=<int>           height"
    1.15 +#    echo "  -q, --quality=<int>          JPEG quality"
    1.16 +#    echo "  -f, --format=[png, jpeg]     save format"
    1.17 +    echo "  -f, --format=[png]           save format"
    1.18 +    echo "  -o, --output=<file>          output filename"
    1.19 +    echo "  -v, --version                show version information"
    1.20 +    echo ""
    1.21 +    echo "Help options:"
    1.22 +    echo "  -?, --help                   Show this help message"
    1.23 +    echo "  --usage                      Display brief usage message"
    1.24 +}
    1.25 +TEMP=`getopt -s bash -o d:p:x:y:w:h:q:f:o:v \
    1.26 +  --long dpi-x:,dpi-y:,x-zoom:,y-zoom:,width:,height:,quality:,format:,output:,version \
    1.27 +  -n 'rsvg' -- "$@"`
    1.28 +if [ $? != 0 ]; then
    1.29 +    usage
    1.30 +    exit 1
    1.31 +fi
    1.32 +eval set -- "$TEMP"
    1.33 +cmd="rsvg"
    1.34 +output="/dev/stdout"
    1.35 +while true; do
    1.36 +    case "$1" in
    1.37 +	-d|--dpi-x|-p|--dpi-y|-x|--x-zoom|-y|--y-zoom|-w|--width|-h|--height)
    1.38 +	    cmd="$cmd $1 $2"
    1.39 +	    shift 2
    1.40 +	    ;;
    1.41 +	-q|--quality)
    1.42 +	    echo "rsvg-convert wrapper: jpeg format not supported"
    1.43 +	    exit 1
    1.44 +	    ;;
    1.45 +	-f|--format)
    1.46 +	    if [ "$2" = "png" -o -z "$2" ]; then
    1.47 +		cmd="$cmd $1 png"
    1.48 +	    else
    1.49 +		echo "rsvg-convert wrapper: $2 format not supported"
    1.50 +		exit 1
    1.51 +	    fi
    1.52 +	    shift 2
    1.53 +	    ;;
    1.54 +	-o|--output)
    1.55 +	    output="$2"
    1.56 +	    shift 2
    1.57 +	    ;;
    1.58 +	-v|--version)
    1.59 +	    cmd="$cmd $1"
    1.60 +	    shift
    1.61 +	    ;;
    1.62 +	--)
    1.63 +	    shift
    1.64 +	    break
    1.65 +	    ;;
    1.66 +	*)
    1.67 +	    echo "Internal error!" >&2
    1.68 +	    exit 1
    1.69 +	    ;;
    1.70 +    esac
    1.71 +done
    1.72 +if [ "$#" -ne 1 ]; then
    1.73 +    usage
    1.74 +    exit 1
    1.75 +fi
    1.76 +input="$1"
    1.77 +exec $cmd "$input" "$output"