]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.0.1
authorfred <fred>
Mon, 27 Jul 1998 18:45:01 +0000 (18:45 +0000)
committerfred <fred>
Mon, 27 Jul 1998 18:45:01 +0000 (18:45 +0000)
buildscripts/ps-to-gifs.sh [new file with mode: 0644]

diff --git a/buildscripts/ps-to-gifs.sh b/buildscripts/ps-to-gifs.sh
new file mode 100644 (file)
index 0000000..a2e9e26
--- /dev/null
@@ -0,0 +1,77 @@
+#!/bin/bash
+# ps-to-gifs, convert PS to multiple gifs
+  
+usage()
+{
+    cat <<EOF
+Usage: ps-to-gifs.sh [OPTION]... [FILE]
+Options:
+  -h, --help         this help
+  -c, --crop         crop output
+  -o, --output=NAME  set output base
+  -t, --transparent  change white to transparent
+EOF
+}
+
+if [ $# -lt 1 ]; then
+    usage;
+    exit 2;
+fi
+CROP=cat
+
+while [ $# -gt 0 ]; do
+opt=$1
+shift
+    case $opt in
+    -t|--t*)
+       color='-transparent white'
+       ;;
+    -h|--h*)
+       usage;
+       exit 0
+       ;;
+    -c|--c*)
+       CROP=" pnmcrop "
+       ;;
+    -o) OUTFILE=$2; shift
+        ;;
+    --o*=*) OUTFILE=`echo $opt | sed -e s/"^.*="//`
+        ;;
+    -*)
+        echo "ps-to-gifs: unknown option: \`$opt'"
+       exit 1
+       ;;
+    *)
+       FILE=$opt
+       ;;
+    esac
+done
+
+if [ "x$TRANSPARENT_IS_BROKEN" != "x" ]; then
+       color=
+fi
+
+if [ "x$OUTFILE" = "x" ]; then
+       BASE=`dirname $FILE`/`basename $FILE .ps`
+else
+       BASE=`dirname $OUTFILE`/`basename $OUTFILE .gif`
+fi
+
+# urg, pipe breaks
+rm -f $BASE{.ppm,.gif} $BASE-page*{.ppm,.gif}
+
+# generate the pixmap at twice the size, then rescale (for antialiasing)
+cat $FILE | gs -sDEVICE=ppmraw -sOutputFile="$BASE-page%d.ppm" -r200 -dNOPAUSE - -c quit $FILE
+# quant is soo slow
+# cat $PPMFILE | ppmquant 2 | pnmscale 0.3333 | pnmcrop | ppmtogif $color > $OUTFILE
+PPMS=`ls $BASE*ppm`
+for i in $PPMS; do
+    o=`dirname $i`/`basename $i .ppm`.gif
+    cat $i | pnmscale 0.5 | $CROP | ppmtogif $color > $o
+    rm $i
+done
+
+if [ "x$OUTFILE" != "x" ]; then
+       mv $BASE-page1.gif $BASE.gif
+fi
+