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
7 # Arg1: Source svg file
8 # Arg2: Filename for copyright notice
9 # Arg3: Target png file
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*}
17 if (gimp --version) >/dev/null 2>&1; then
18 echo "Converting $1 to $3 size $widthx$width with GIMP"
20 # If no width can be extracted from the destination path
21 # then take the natural width by setting width to 0
23 [0-9][0-9] | [0-9][0-9][0-9]) ;;
27 (let* ((image (car (file-svg-load 1 \"$1\" \"$1\" 90 $width $width 0 ))))
28 (gimp-image-attach-parasite image '(\"gimp-comment\" 0 \"$comment\"))
29 (gimp-file-save 1 image (car (gimp-image-get-active-drawable image))
32 elif (rsvg-convert --version) >/dev/null 2>&1; then
33 echo "Converting $1 to $3 size $widthx$width with rsvg-convert"
35 [0-9][0-9] | [0-9][0-9][0-9]) widthoption="--width=$width --height=$width" ;;
38 rsvg-convert $widthoption "$1" > "$3"
40 echo "$0: can't find gimp or rsvg-convert" >&2