X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=build-aux%2Fsvg2png;h=f98b76cea7a812fed8ac98139f78bd2d9d328ab5;hb=328f9a9c6219e432140ad846c1c08f1856aa8b39;hp=c6165a7c55095bc6951f4a12a0c3aec778d57380;hpb=0149e6c64281797ea7da1679d0d9ec1c4443061a;p=pspp diff --git a/build-aux/svg2png b/build-aux/svg2png index c6165a7c55..f98b76cea7 100755 --- a/build-aux/svg2png +++ b/build-aux/svg2png @@ -1,8 +1,31 @@ #! /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*} + +# If no width can be extracted from the destination path +# then take the natural width by setting width to 0 +case "$width" in + [0-9][0-9]|[0-9][0-9][0-9]) ;; + *) width="0";; +esac + +echo "Converting" $1 "to" $3 "size" $width"x"$width + comment=`cat $2` -gimp -i -b "\ -(let* ((image (car (gimp-file-load 1 \"$1\" \"$1\")))) +gimp -i -d -b "\ +(let* ((image (car (file-svg-load 1 \"$1\" \"$1\" 90 $width $width 0 )))) (gimp-image-attach-parasite image '(\"gimp-comment\" 0 \"$comment\")) (gimp-file-save 1 image (car (gimp-image-get-active-drawable image)) \"$3\" \"$3\"))