#! /usr/bin/perl # Copyright (C) 2000, 2001 Kaoru Maeda. # All rights reserved. # This file can be freely distributed # under the same condition as Perl. $argc = 0; $opt_resolution = "800x600"; $opt_opts = ""; while ($argc <= $#ARGV) { if ($ARGV[$argc] eq "-h" || $ARGV[$argc] eq "--help") { "$0 [-g WIDTHxHEIGHT] [-o mgp-option] mgp-file\n"; exit; } elsif ($ARGV[$argc] eq "-g") { if (($argc < $#ARGV) && ($ARGV[$argc+1] !~ /^-/)) { $opt_resolution = $ARGV[++$argc]; } } elsif ($ARGV[$argc] eq "-o") { if (($argc < $#ARGV)) { $opt_opts = $ARGV[++$argc]; } } else { $stem = $ARGV[$argc]; $stem =~ s/\.mgp?//; } $argc++; } $tmpdir = "PRINT6"; @PAGES = glob("$tmpdir/mgp00???.eps"); if (!-d $tmpdir || !@PAGES) { if (-d $tmpdir) { system("rm -rf $tmpdir"); } mkdir $tmpdir, 0777; system("mgp -D $tmpdir -E png -o -g $opt_resolution+0+0 -X ppmraw+ $opt_opts $stem.mgp"); @PNGS = glob("$tmpdir/mgp00???.png"); for $png (@PNGS) { ($eps = $png) =~ s/\.png/.eps/; print STDERR "$png -> $eps\n"; system("pngtopnm $png | ppmtopgm | perl -pe 'tr/\\372/\\377/' | pnmtops -dpi 600 -scale 0.6 -noturn > $eps"); } @PAGES = glob("$tmpdir/mgp00???.eps"); } $pages = 0; $o = 0; @LOC = ('48,128,509,474', '544,128,1005,474', '48,576,509,922', '544,576,1005,922', '48,1024,509,1370', '544,1024,1005,1370', ); while (@PAGES) { @P = splice(@PAGES, 0, scalar @LOC); $pages++; push(@out, qq[page($pages,"",1,'').\n]); @loc = @LOC; for $file (@P) { $mtime = (stat $file)[9]; $mtime = localtime($mtime); $loc = shift(@loc); $x = <$stem-6.obj"); print OUT @out; close OUT; system("tgif -print -ps $stem-6.obj"); unlink("$stem-6.obj"); __END__