summaryrefslogtreecommitdiff
path: root/obsolete/macros/latex209/contrib/epsfig/epsbb
blob: 8e8fbccab199eee9ceac156b9b86a452a4971fd3 (plain)
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
#!/usr/local/bin/perl
#
# Extract Bounding Box *.bb and compress postscript figure files.
#
# usage: epsbb          --- For all files in the current directory.
#        epsbb DIR      --- For all files in the directory DIR.
#        epsbb FILES... --- For all the FILES on the command line
#
#  Author: Peter Whaite (peta@mcrcim.mcgill.edu)
#          Centre for Intelligent Machines, McGill University.
$RCSVERSION='$Id: epsbb,v 1.2 1993/09/05 20:16:45 peta Exp $';

## USER CONFIG -- edit the following to suit your system.
#
$GZIP='/usr/local/bin/gzip';
$ZCAT='/usr/local/bin/gunzip -c';
#
## END USER CONFIG

@ARGV=<*> unless ($#ARGV>=0);	                    # epsbb
@ARGV=<$ARGV[0]/*> if ($#ARGV==0 && (-d $ARGV[0])); # epsbb DIR

FILE: while ($_=shift)
{
    /\.bb$/ && next;
    -e ($eps=$_) || -e ($eps="$_.gz") || -e ($eps="$_.z") || -e ($eps="$_.Z")
	|| do { warn("$_ does not exist\n"); next;};
    -f $eps || do { warn("$eps not a plain file\n"); next;};
    $epsf = $eps;
    $compressed = 0;
    $eps =~ /^(.*)\.(gz|z|Z)$/ && do
    {
	$eps = $1;
	$epsf = "$ZCAT $eps|";
	$compressed = 1;
    };
    
    open(EPS,$epsf) || do {warn("$0: $epsf: $!\n"); next;};
    while (<EPS>)
    {
	/^%[%\w]*BoundingBox/ && do
	{
	    open(BB,">$eps.bb") || do
	    {
		warn("$0: $eps.bb: $!\n");
		next FILE;
	    };
	    print STDERR "Writing $eps.bb";
	    print BB;
	    close BB;
	    if (!$compressed)
	    {
		print STDERR ", compressing $eps...";
		system("$GZIP $eps") unless $compressed;
	    }
	    print STDERR "\n";
	    close EPS;
	    next FILE;
	};
    };
    close EPS;
    warn("$eps has no bounding box\n");
}

# Local Variables:
# mode: perl
# auto-fill-hook: do-auto-fill
# End: