config/rsvg_convert
author J. Ali Harlow <ali@juiblex.co.uk>
Mon Aug 31 07:07:40 2020 +0100 (2020-08-31)
changeset 103 c4b0d5cc34bc
permissions -rw-r--r--
Add support for --default-action in app-manager
     1 #!/bin/bash
     2 # A compatibility wrapper for rsvg that makes it act like rsvg-convert
     3 usage()
     4 {
     5     echo "Usage: rsvg [OPTIONS...] file.svg"
     6     echo "  -d, --dpi-x=<float>          pixels per inch"
     7     echo "  -p, --dpi-y=<float>          pixels per inch"
     8     echo "  -x, --x-zoom=<float>         x zoom factor"
     9     echo "  -y, --y-zoom=<float>         y zoom factor"
    10     echo "  -w, --width=<int>            width"
    11     echo "  -h, --height=<int>           height"
    12 #    echo "  -q, --quality=<int>          JPEG quality"
    13 #    echo "  -f, --format=[png, jpeg]     save format"
    14     echo "  -f, --format=[png]           save format"
    15     echo "  -o, --output=<file>          output filename"
    16     echo "  -v, --version                show version information"
    17     echo ""
    18     echo "Help options:"
    19     echo "  -?, --help                   Show this help message"
    20     echo "  --usage                      Display brief usage message"
    21 }
    22 TEMP=`getopt -s bash -o d:p:x:y:w:h:q:f:o:v \
    23   --long dpi-x:,dpi-y:,x-zoom:,y-zoom:,width:,height:,quality:,format:,output:,version \
    24   -n 'rsvg' -- "$@"`
    25 if [ $? != 0 ]; then
    26     usage
    27     exit 1
    28 fi
    29 eval set -- "$TEMP"
    30 cmd="rsvg"
    31 output="/dev/stdout"
    32 while true; do
    33     case "$1" in
    34 	-d|--dpi-x|-p|--dpi-y|-x|--x-zoom|-y|--y-zoom|-w|--width|-h|--height)
    35 	    cmd="$cmd $1 $2"
    36 	    shift 2
    37 	    ;;
    38 	-q|--quality)
    39 	    echo "rsvg-convert wrapper: jpeg format not supported"
    40 	    exit 1
    41 	    ;;
    42 	-f|--format)
    43 	    if [ "$2" = "png" -o -z "$2" ]; then
    44 		cmd="$cmd $1 png"
    45 	    else
    46 		echo "rsvg-convert wrapper: $2 format not supported"
    47 		exit 1
    48 	    fi
    49 	    shift 2
    50 	    ;;
    51 	-o|--output)
    52 	    output="$2"
    53 	    shift 2
    54 	    ;;
    55 	-v|--version)
    56 	    cmd="$cmd $1"
    57 	    shift
    58 	    ;;
    59 	--)
    60 	    shift
    61 	    break
    62 	    ;;
    63 	*)
    64 	    echo "Internal error!" >&2
    65 	    exit 1
    66 	    ;;
    67     esac
    68 done
    69 if [ "$#" -ne 1 ]; then
    70     usage
    71     exit 1
    72 fi
    73 input="$1"
    74 exec $cmd "$input" "$output"