Root/scripts/schps2ppm

Source at commit b3f201486360ad2ffeb7d1ac24d14972d850f8ca created 10 years 24 days ago.
By Werner Almesberger, Split gitsch2ppm into its constituents.
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
15RES=1280x850
16
17
18usage()
19{
20    cat <<EOF 1>&2
21usage: $0 [options] [file.ps [file.ppm]]
22
23  -r XxY image resolution (default: $RES)
24EOF
25    exit 1
26}
27
28
29while true; do
30    case "$1" in
31    -r) [ -z "$2" ] && usage
32    RES="$2"
33    shift 2;;
34    -*)
35    usage;;
36    *)
37    break;;
38    esac
39done
40
41[ ! -z "$3" ] && usage
42in=${1:--}
43out=${2:-/dev/stdout}
44
45X=`echo $RES | sed 's/x.*//'`
46Y=`echo $RES | sed 's/.*x//'`
47IRES=${Y}x$X
48res=`expr 72 \* $X / 800`
49
50cat "$in" |
51  gs -sDEVICE=ppmraw -sOutputFile=- -g$IRES -r$res \
52  -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q - |
53  pnmflip -r270 >"$out"
54

Archive Download this file



interactive