work on docs
[pspp] / build-aux / svg2png
1 #! /bin/sh
2
3 # Convert svg file to png with a target width and height
4 # width and height are derived from the directory name
5 # of the target. Width and height must be equal
6
7 # Arg1: Source svg file
8 # Arg2: Filename for copyright notice
9 # Arg3: Target png file
10
11 # Extract the icon width from the target path e.g.
12 # src/ui/gui/icons/48x48/actions/file-save.png
13 # should result in a width of 48
14 stripprefix=${3#src*icons\/}
15 width=${stripprefix%%x*}
16
17 # If no width can be extracted from the destination path
18 # then take the natural width by setting width to 0
19 case "$width" in
20     [0-9][0-9]|[0-9][0-9][0-9])  ;;
21     *)                 width="0";;
22 esac
23
24 echo "Converting" $1 "to" $3 "size" $width"x"$width
25
26 comment=`cat $2`
27 gimp -i -d -b "\
28 (let* ((image (car (file-svg-load 1 \"$1\" \"$1\" 90 $width $width 0 ))))
29       (gimp-image-attach-parasite image '(\"gimp-comment\" 0 \"$comment\"))
30       (gimp-file-save 1 image (car (gimp-image-get-active-drawable image))
31                       \"$3\" \"$3\"))
32     (gimp-quit 1)"