Root/
| 1 | #!/bin/sh |
| 2 | # |
| 3 | # schps2ppm - Generate PPM files from normalized Eeschema Postscript |
| 4 | # |
| 5 | # Written 2010 by Werner Almesberger |
| 6 | # Copyright 2010 Werner Almesberger |
| 7 | # |
| 8 | # This program is free software; you can redistribute it and/or modify |
| 9 | # it under the terms of the GNU General Public License as published by |
| 10 | # the Free Software Foundation; either version 2 of the License, or |
| 11 | # (at your option) any later version. |
| 12 | # |
| 13 | |
| 14 | |
| 15 | RES=1280x850 |
| 16 | |
| 17 | |
| 18 | usage() |
| 19 | { |
| 20 | cat <<EOF 1>&2 |
| 21 | usage: $0 [options] [file.ps [file.ppm]] |
| 22 | |
| 23 | -n disable alpha blending |
| 24 | -r XxY image resolution (default: $RES) |
| 25 | EOF |
| 26 | exit 1 |
| 27 | } |
| 28 | |
| 29 | |
| 30 | alpha=true |
| 31 | while true; do |
| 32 | case "$1" in |
| 33 | -n) alpha=false |
| 34 | shift;; |
| 35 | -r) [ -z "$2" ] && usage |
| 36 | RES="$2" |
| 37 | shift 2;; |
| 38 | -) break;; |
| 39 | -*) usage;; |
| 40 | *) break;; |
| 41 | esac |
| 42 | done |
| 43 | |
| 44 | [ ! -z "$3" ] && usage |
| 45 | in=${1:--} |
| 46 | out=${2:-/dev/stdout} |
| 47 | |
| 48 | X=`echo $RES | sed 's/x.*//'` |
| 49 | Y=`echo $RES | sed 's/.*x//'` |
| 50 | IRES=${Y}x$X |
| 51 | res=`expr 72 \* $X / 800` |
| 52 | |
| 53 | cat "$in" | |
| 54 | gs -sDEVICE=ppmraw -sOutputFile=- -g$IRES -r$res \ |
| 55 | `$alpha && echo '' -dTextAlphaBits=4 -dGraphicsAlphaBits=4` \ |
| 56 | -q - | |
| 57 | pnmflip -r270 >"$out" |
| 58 |
Branches:
master
