File: plm2gif

package info (click to toggle)
plplot 5.10.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 26,280 kB
  • ctags: 13,512
  • sloc: ansic: 83,001; xml: 27,081; ada: 18,878; cpp: 15,966; tcl: 11,651; python: 7,075; f90: 7,058; ml: 6,974; java: 6,665; perl: 5,029; sh: 2,210; makefile: 199; lisp: 75; sed: 25; fortran: 7
file content (74 lines) | stat: -rwxr-xr-x 2,132 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh
############################################################################
#
# $Id: plm2gif 1443 1995-01-11 19:43:53Z mjl $
#
# File: plm2gif
# Usage: plm2gif [files] 
#
# Maurice J. LeBrun (mjl@dino.ph.utexas.edu)
# Institute for Fusion Studies, University of Texas
# 10-Jan-95
#
# Converts specified PLplot metafiles to GIF format files.  This is a
# two-step process:
#   1. process into postscript (with custom flags)
#   2. convert to GIF using ghostscript (more custom flags)
#
# Each input file must end with ".plm", and a corresponding family of GIF
# files ending with "<number>.gif" (one for each page) is created.
#
# The PLplot and ghostscript flags are chosen so that the output GIF file
# plots have the correct aspect ratio.  This is complicated by the need to
# swap the postscript orientation into landscape mode.  The GIF files
# created are by default of resolution 640x480 or less.  To change, modify
# $res accordingly (note: Y-res must be exactly 9/16 of X-res in order for
# the plots to have the correct aspect ratio).
#
############################################################################

# Settings

gs="gs"
res="75.3x42.36"	# 640 x 466
#res="94.1x52.93"	# 800 x 582

# First find plrender and check version.
# Have to be a bit clever here since old versions of plrender returned an
# error code of 1 when passed the -v flag.

plversion=`plrender -v 2>&1 | awk 'NR == 2 {print $NF}'` || {
    echo "How odd, don't you have awk?  Aborting."
    exit 1
}

if test -z "$plversion"; then
    echo "plrender not found, aborting"
    exit 1
fi

if test `expr "$plversion" \< "4.99j"` -eq 1; then
    echo "Must be running PLplot version 4.99j or later"
    exit
fi

# Now find ghostscript

gs_out=`$gs -v 2>&1` || {
    echo "ghostscript ($gs) not found, aborting"
    exit 1
}

# Finally, process files.

for arg in $*
    do
    if test -f $arg; then
	echo "Processing $arg.."
	name=`basename $arg .plm`
	plrender -dev psc -o $name.ps -ori 3 -freeaspect $arg >/dev/null 2>&1
	$gs -sDEVICE=gif8 -r$res -sOutputFile=$name%d.gif $name.ps \
	    </dev/null >/dev/null 2>&1 
    fi
done
exit 0