Address allocation stats

Daniel W. McRobb dwm at ans.net
Tue Jun 18 20:10:53 UTC 1996


> > I've just updated the graphs for the data through the end of May.
> > These'll be the ones I'll be bringing to Montreal and are very
> > similar to the ones from LA -- assuming no other changes.
> > 
> > The postscript files can also be copied from:
> > 	ftp://research.ftp.com/pub/cidr/current
> > 
> > If I get a chance this week, I'll also look for a .ps->.gif converter..
> 
> You've just found one.  Me. ;-)
> 
> Seriously, you need GhostScript 2.6.1 with the following
> modification to gdevgif.c:
> 
> /* #define TABLE_SIZE 5123              /* this is max for 12-bit codes */
> #define TABLE_SIZE 5119         /* this is max for 12-bit codes (and prime) */
> 
> 5123 is nice, but not prime, and this will in certain
> circumstances produce an infinite CPU-consuming loop.
> 
> Second, uncomment the "30000 VM?" test in the PS files.
> 
> Third you will need the ps-to-gif script (a one-liner in the
> shell given the right gs) and the landscape.ps which is available
> together with the already converted (gif) files in
> 
> 	ftp://trane.uninett.no/tmp/pier/
> 
> Note that a newer version of GhostScript won't do, since they
> removed the GIF driver in subsequent versions to 2.6.1 (you
> probably know why...).
> 
> Regards,
> 
> - Havard

However, newer versions of ghostscript have no problem creating ppm
files (if you compile w/ ppm driver), and you can use them along with
'pstogif' to generate GIF files.  'pstogif' is just a perl script that
runs gs to generate ppm, then pnmcrop, ppmquant and ppmtogif (from the
netpbm package).  Also, 'convert' in the ImageMagick package will work
as well, and does something similar (i.e. I think you still need
ghostscript with ppm).  I don't normally use 'convert' for PostScript to
GIF conversion though, since I've found it to be a lot slower than
'pstogif'.

I don't remember where I got 'pstogif' (maybe the CTAN archive?), so
here it is (albeit with my change to use a FIFO to speed things up a
bit).

Daniel
~~~~~~

#!/usr/local/bin/perl
# 
# pstogif.pl v1.0, July 1994, by Nikos Drakos <nikos at cbl.leeds.ac.uk>
# Computer Based Learning Unit, University of Leeds.
#
# Accompanies LaTeX2HTML Version 95
#
# Script to convert an arbitrary PostScript image to a cropped GIF image
# suitable for incorporation into HTML documents as inlined images to be
# viewed with WWW browsers.
#
# This is based on the pstoepsi script 
# by Doug Crabill dgc at cs.purdue.edu
#
# Please note the following:
# - The source PostScript file must end
#   in a .ps extention.  This is a GhostScript requirement, not mine...
# - The -density argument has no effect unless the 
#   color depth (set with the -depth argument) is equal to 1.
# - Valid arguments for -depth are 1,8, or 24.
#  
# This software is provided as is without any guarantee.
#
# Nikos Drakos (ND), nikos at cbl.leeds.ac.uk
# Computer Based Learning Unit, University of Leeds.
#
# 20 JUL 94 ND Converted to Perl and made several changes eg it now accepts 
#    parameters from environment variables or from command line or will use 
#    default ones. 
#      
# 1  APR 94 ND Changed the suffixes of multi-page files from xbm to gif (oops!)
#
# 

#####################################################################
$| =1;
&read_args;

### You may need to specify some pathnames here if you want to
### run the script without LaTeX2HTML

# Ghostscript
$GS= $ENV{'GS'} || 'gs';

# Comes with LaTeX2HTML (For ghostscript versions greater than 3.0 
# you need the newer pstoppm.ps)
$PSTOPPM= $ENV{'PSTOPPM'} ||
    '/usr/local/lib/ghostscript/pstoppm.ps';

# Available in the PBMPLUS libary	   
$PNMCROP=$ENV{'PNMCROP'} || '/u/dwm/bin/pnmcrop' ;

# Also in PBMPPLUS	  
$PPMTOGIF=$ENV{'PPMTOGIF'} || '/u/dwm/bin/ppmtogif' ;

# Also in PBMPPLUS	  
$REDUCE_COLOR=$ENV{'PPMQUANT'} || '/u/dwm/bin/ppmquant 256' ;
 
$OUTFILE = $ENV{'OUTFILE'} || $out;
			
# Valid choices for $COLOR_DEPTH are 1, 8 or 24. 
$DEPTH = $ENV{'DEPTH'} || $depth || 24;

#Default density is 72
$DENSITY = $ENV{'DENSITY'} || $density || 72;
    
# Valid choices are any numbers greater than zero
# Useful choices are numbers between 0.1 - 5
# Large numbers may generate very large intermediate files
# and will take longer to process
$SCALE = $ENV{'SCALE'} || $scale; # No default value

$PAPERSIZE = $ENV{'PAPERSIZE'} || $papersize; # No default value;

$DEBUG = $ENV{'DEBUG'} || $DEBUG || 0;

######################################################################

&main;

sub read_args {
    local($_);
    while ($ARGV[0] =~ /^-/) {
	$_ = shift @ARGV;
	if (/^-h(elp)?$/) {
	    &usage; exit;}
        elsif (/^-out$/) {
            $out = shift @ARGV;
	}
	elsif (/^-(.*)$/) {
	    eval "\$$1 = shift \@ARGV;"; # Create and set a flag $<name>
	    }
    }
}		 

sub main {
    local($base, $outfile, $i, $j);
    $base = &test_args;
    $outfile = $OUTFILE || "$base.gif";
    open(STDERR, ">/dev/null") unless $DEBUG;
    system("/usr/bin/mkfifo $base.ppm");
    &crop_scale_etc("$base.ppm", $outfile);
    &convert($base);
    &cleanup($base);
}

sub crop_scale_etc {
    local($in, $out) = @_;
    open(STDERR, ">/dev/null") unless $DEBUG;
    system("$PNMCROP $in |$REDUCE_COLOR |$PPMTOGIF  - > $out &");
    print "Writing $out\n";
}

sub test_args {
    local($file) = $ARGV[0];
    if (! ($file =~ s/\.ps$//)) {
	print "The name of the input file must end in '.ps'\n";
	exit;}
    elsif (! ( -f "$file.ps")) {
	print "Cannot find file $file.ps\n.";
	exit;}
    elsif (! ($DEPTH =~ /^(1|8|24)$/)) {
	print "The color depth must be 1 or 8 or 24. You specified $DEPTH\n";
	exit;
	}
    if (defined $SCALE) {
	if ($SCALE > 0) {
	    $DENSITY = int($SCALE * 72);}
	else {
	    print "Error: The scale must be greater than 0.\n" .
		"You specified $SCALE\n";
	    exit;}
    }
    $file;
}
   
sub convert {
    local($base) = @_;
    local($paperopt) = "-sPAPERSIZE=$PAPERSIZE" if $PAPERSIZE;
    local($ppmtype) = join('', "ppm",$DEPTH,"run");
    open (GS, "|$GS -q $paperopt -dNODISPLAY $PSTOPPM -");
    print GS "$DENSITY $DENSITY ppmsetdensity\n";
    print GS "ppmsetsize2$PAPERSIZE % thanks to wsineric\@win.tue.nl (Eric Verbeek)\n" if $PAPERSIZE;
    print GS "($base) $ppmtype\n";
    close GS;
}

sub cleanup {
    local($base) = @_;
#    unlink <$base[0-9.]*ppm>;
}

sub usage {
    print "Usage: pstogif [-h(elp)] [-out <output file>] [-depth <color depth 1, 8 or 24>]  [-density <pixel density>] <file>.ps\n\n";
}





More information about the NANOG mailing list