Wikipedia:WikiProject Chemistry/Structure drawing workgroup/Mysid's script: Difference between revisions

Content deleted Content added
Remove cropping code (better to do it in BKchem)
cleaner filename usage and error handling
Line 4:
use Image::Magick;
 
@ARGV == 1 or die "Usage: $! FILENAME.svg\n";
#Does the input file exist?
 
if(! -f $ARGV[0])
#Open files
{print "$ARGV[0]: File not found\n";
if(!$infile -f= $ARGV[0]);
exit};
open INPUT, '<', $infile or die "Could not read $infile: $!\n";
#Open files. TODO: check that output file is writeable.
$outfile1 = $ARGV[0]infile;
open INPUT,"<$ARGV[0]";
$outfile1 = $ARGV[0];
$outfile1 =~ s/.svg/1.svg/;
open OUTPUT," '>', $outfile1 or die "Could not write $outfile1: $!\n";
 
while (<INPUT>) {
Line 59 ⟶ 58:
 
 
open INPUT," '<', $outfile1 or die "Could not read $outfile1: $!\n";
$outfile2 = $ARGV[0]infile;
$outfile2 =~ s/.svg/2.svg/;
open OUTPUT," '>' $outfile2 or die "Could not write $outfile2: $!\n";
while (<INPUT>) {
#Take out redundant groups.