X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=build-aux%2Fsvg2png;h=3ba9d6ac9ee0fb82291795e4005d2298ebe23853;hb=6d7eed1c12693a3688a3c16f634a5b816660085b;hp=5c41840c5154e1c78387457cd3ed14d42da308be;hpb=f2d4cc6e7a4d5948a2c0cf70883347000a79a2b0;p=pspp diff --git a/build-aux/svg2png b/build-aux/svg2png index 5c41840c51..3ba9d6ac9e 100755 --- a/build-aux/svg2png +++ b/build-aux/svg2png @@ -1,9 +1,22 @@ #! /bin/sh +# Convert svg file to png with a target width and height +# width and height are derived from the directory name +# of the target. Width and height must be equal + +# Arg1: Source svg file +# Arg2: Filename for copyright notice +# Arg3: Target png file + +# Extract the icon width from the target path e.g. +# src/ui/gui/icons/48x48/actions/file-save.png +# should result in a width of 48 +stripprefix=${3#src*icons\/} +width=${stripprefix%%x*} + comment=`cat $2` -gimp -i -b "\ -(let* ((image (car (gimp-file-load 1 \"$1\" \"$1\")))) - (gimp-image-attach-parasite image (list \"gimp-comment\" 0 \"$comment\")) - (gimp-file-save 1 image (car (gimp-image-get-active-drawable image)) - \"$3\" \"$3\")) - (gimp-quit 1)" +case $width in + [0-9][0-9] | [0-9][0-9][0-9]) widthoption="--width=$width --height=$width" ;; + *) widthoption= ;; +esac +rsvg-convert $widthoption "$1" | ${PYTHON3:-python3} build-aux/png-add-comment Comment "$comment" > "$3"