diff options
author | Stefan Wildemann <metalstrolch@users.noreply.github.com> | 2017-12-04 11:53:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-04 11:53:01 +0100 |
commit | 39a8259e6d7d31e120ee5309e6a92760f08e43c9 (patch) | |
tree | c4ec096cf677f31a0c459d920a443b3596c60e9b /navit/icons/navit_svg2png | |
parent | 0898653cefd5b32db8646516c3bf2cce9baa4b15 (diff) | |
parent | 3584d6ece6016969a1a5a8b56879fa9ea4dfc0fe (diff) | |
download | navit-39a8259e6d7d31e120ee5309e6a92760f08e43c9.tar.gz |
Merge branch 'trunk' into icon_goverment_building
Diffstat (limited to 'navit/icons/navit_svg2png')
-rwxr-xr-x | navit/icons/navit_svg2png | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/navit/icons/navit_svg2png b/navit/icons/navit_svg2png index 675207561..668613a61 100755 --- a/navit/icons/navit_svg2png +++ b/navit/icons/navit_svg2png @@ -1,5 +1,14 @@ #!/bin/sh +exitwithhelp() +{ + echo "Usage: navit_svg2png <conversion_tool> <output_png_filename> [<width_px> <height_px>]" + echo "The input filename is the same than the output png one with svg or svgz extension" + echo "Possible conversion tools: ksvgtopng, ksvgtopng4, rsvg-convert, inkscape and convert" + echo "width_px and height_px arguments can be omitted if output png size is specified in the filename, like this: imagename_WIDTH_HEIGHT.png (ex. myPng_100_100.png)" + exit +} + svgtopng() { case $svgtopng in @@ -15,6 +24,10 @@ svgtopng() *convert) $svgtopng -alpha on -background none $3 -resize $1x$2 $4 ;; + *) + echo "Error: unknown conversion tool" + exitwithhelp # unknown conversion tool + ;; esac } @@ -26,8 +39,27 @@ svgtopng=$1 png=$2 w=$3 h=$4 + +# if -h or --help arg is passed, print help and exit +case "$1" in + '-h'|'--help'|'') + exitwithhelp + ;; +esac + +# args num must be == 2 or == 4 +if [ "$#" -ne 2 ] && [ "$#" -ne 4 ]; +then + echo "Error: wrong number of arguments" + exitwithhelp +fi + case "$png" in *_[1-9]*_[1-9]*.png) + if [ "$#" -ne 2 ]; then + echo "Error: output png size is specified by filename and by arguments, plese use only one" + exitwithhelp # png size musn't be specifed, only in filename + fi svg=${png%_*_*.png}; h=${png##*_} w=${png%_$h} @@ -35,6 +67,10 @@ case "$png" in w=${w##*_} ;; *) + if [ "$#" -ne 4 ]; then + echo "Error: please, specify output png size" + exitwithhelp # filename doesn't specify png size, must be done with args 3 and 4 + fi svg=${png%.png} ;; esac |