#!/usr/bin/perl -w # # ps2png [resolution] file... # # Convert a postscript file to PNG, using the gs (GhostScript) command. The # resolution defaults to 85, which is a readable compromise for most screens. # The files should be postscript files. You can omit a .ps suffix and we'll # assume it. # Author: John Chambers $ENV{LD_LIBRARY_PATH} = '/usr/X11R6/lib/:/usr/eecs/lib:/usr/lib:/usr/lib/aout'; if (($res = $ARGV[0]) =~ /^\d+$/) {shift @ARGV} else {$res = 85} file: for $file (@ARGV) { if ($file =~ /(.*)\.(\w*ps)$/i) { $fili = $file; $filo = "$1.png"; } else { if (-f ($fili = "$file.ps" )) {$filo = "$file.png"; } elsif (-f ($fili = "$file.eps")) {$filo = "$file.png"; } elsif (-f ($fili = "$file.PS" )) {$filo = "$file.PNG"; } else { print STDERR "Can't find postscript file for $file.\n"; next file; } } system "gs -q -DNOPAUSE -sDEVICE=ppmraw -r$res -sOutputFile='|pnmcrop|wpng >$filo' -- $fili"; if ($?) { print STDERR "Conversion of \"$fili\" failed with exit status $?.\n"; exit $?; } }