blob: 16ecfb7e2e39b28b51e6d570b0dc99e2d3668c80 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#!/bin/sh
svgtopng()
{
case $svgtopng in
*ksvgtopng|*ksvgtopng4)
$svgtopng $*
;;
*rsvg-convert)
$svgtopng --width=$1 --height=$2 --output $4 $3
;;
*inkscape)
$svgtopng --without-gui --export-width=$1 --export-height=$2 --export-png=$BUILDDIR/$4 $3
;;
*convert)
$svgtopng $3 -resize $1x$2 $4
;;
esac
}
if [ "$OSTYPE" != "cygwin" -a "$OSTYPE" != "msys" ]; then
ulimit -t 10
fi
svgtopng=$1
png=$2
case "$png" in
*_[1-9]*_[1-9]*.png)
svg=${png%_*_*.png};
h=${png##*_}
w=${png%_$h}
h=${h%.png}
w=${w##*_}
;;
*)
svg=${png%.png}
;;
esac
if [ ! -f $svg.svg -a ! -f $svg.svgz ]
then
svg="$SRCDIR/$svg"
fi
if [ -f $png -a ! -f $svg.svg ]; then
# width and height seems to be defined as part of the file name
touch $png
else
# use width and height from the svg image
if [ -f $svg.svg ]
then
if [ -z "$w" ]
then
w=$(grep 'width="[0-9pxt.]*"' $svg.svg | head -n 1 | sed -e 's/.*width="//' -e 's/[pxt]*".*//')
fi
if [ -z "$h" ]
then
h=$(grep 'height="[0-9pxt.]*"' $svg.svg | head -n 1 | sed -e 's/.*height="//' -e 's/[pxt]*".*//')
fi
svgtopng $w $h $svg.svg $png
elif [ -f $svg.svgz ]
then
gzip -dc <$svg.svgz >$svg.svg
if [ -z "$w" ]
then
w=$(grep 'width="[0-9pxt.]*"' $svg.svg | head -n 1 | sed -e 's/.*width="//' -e 's/[pxt]*".*//')
fi
if [ -z "$h" ]
then
h=$(grep 'height="[0-9pxt.]*"' $svg.svg | head -n 1 | sed -e 's/.*height="//' -e 's/[pxt]*".*//')
fi
svgtopng $w $h $svg.svg $png
rm -f $svg.svg
fi
fi
exit 0
|