Root/scripts/schps2ppm

Source at commit 36e73c4abb520aa65722ef5e1483bcb8b75bf9f4 created 13 years 6 months ago.
By Werner Almesberger, Moved tools/ out of atrf, in preparation of merge with atusd.
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  -n disable alpha blending
24  -r XxY image resolution (default: $RES)
25EOF
26    exit 1
27}
28
29
30alpha=true
31while 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
42done
43
44[ ! -z "$3" ] && usage
45in=${1:--}
46out=${2:-/dev/stdout}
47
48X=`echo $RES | sed 's/x.*//'`
49Y=`echo $RES | sed 's/.*x//'`
50IRES=${Y}x$X
51res=`expr 72 \* $X / 800`
52
53cat "$in" |
54  gs -sDEVICE=ppmraw -sOutputFile=- -g$IRES -r$res \
55   `$alpha && echo '' -dTextAlphaBits=4 -dGraphicsAlphaBits=4` \
56   -q - |
57  pnmflip -r270 >"$out"
58

Archive Download this file



interactive