<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl -w
use strict;

use Getopt::Long;

my $help = 0;
my $max = 1;
my $outfile = 'chmout';
my $namefile = 0;
my $ext = 'jpg';

GetOptions(
	   "help" =&gt; \$help,
	   "n=i" =&gt; \$max,
	   "format=s" =&gt; \$ext,
	   "outfile=s" =&gt; \$outfile,
	   "namefile!" =&gt; \$namefile
	   );

if ($help or scalar(@ARGV)==0 ) {
    print &lt;&lt;EOH;
	
makePics.pl is a script to convert documents with OCHEM formula files
into EPS and other graphics formats.

Usage:
makePics.pl [--n=&lt;n&gt;] [--outfile=&lt;outfile&gt;] [--[no]namefile]
            [--format=&lt;format&gt;] &lt;infile&gt;

    --n=&lt;n&gt; sets the number of formulae to process (should be as big as
           there are formula in your document)
    --outfile=&lt;outfile&gt; sets the output file base name, appends also the
           running number to this base name
    --namefile uses the file &lt;infile&gt;.names for naming the resulting EPS-
           and other picture files.
    --format=&lt;format&gt; sets the output format the EPS should be converted into.
           use the extension specifications (jpg, png ...) ImageMagick
           use to determine the format.

Defaults:
    --outfile=$outfile
    --format=$ext
    --n=$max
    --nonamefile

EOH
    exit(0);
}

my $infile = $ARGV[0];

if ($namefile) {
    my $i = 0;
    open(NAMES, "$infile.names") or die "cannot find names file $namefile.names";
    while (my $name = &lt;NAMES&gt;) {
	chomp($name);
	$i++;
	print "converting $i. formula of $infile [$name] into $name.eps and $name.$ext ...\n";
	system("dvips -E -n 1 -p $i -o $name.eps $infile");
	system("convert $name.eps $name.$ext");
	if ($ext eq 'png') {
	    system("mv $name.png.0 $name.png");
	    system("rm $name.png.1");
	}
    }
    close(NAMES);
} else {
    for (my $i=1; $i&lt;=$max; $i++) {
	print "converting $i. formula of $infile into $outfile$i.eps and $outfile$i.$ext ...\n";
	system("dvips -E -n 1 -p $i -o $outfile$i.eps $infile");
	system("convert $outfile$i.eps $outfile$i.$ext");
    }
}


</pre></body></html>