[system] / trunk / webwork2 / bin / math2img Repository:
ViewVC logotype

View of /trunk/webwork2/bin/math2img

Parent Directory Parent Directory | Revision Log Revision Log


Revision 432 - (download) (annotate)
Fri Jul 19 02:39:16 2002 UTC (10 years, 10 months ago) by sh002i
File size: 771 byte(s)
added: math2img and support files... probably shouldn't distribute pip
with WeBWorK, but no one's going to complain, since it's in the public
domain (and that's one less dependancy ;)
-sam

    1 #!/usr/local/bin/perl
    2 
    3 use strict;
    4 use warnings;
    5 use IPC::Open2;
    6 
    7 use constant HEADER => <<EOF;
    8 % BEGIN HEADER
    9 \\documentclass{article}
   10 \\begin{document}
   11 \\huge
   12 \\pagestyle{empty}
   13 % END HEADER
   14 EOF
   15 use constant FOOTER => <<EOF;
   16 % BEGIN FOOTER
   17 \\end{document}
   18 % END FOOTER
   19 EOF
   20 
   21 my $TEX      = "pip_latex";
   22 my $DVIPS    = "pip -o -i dvips -E -q -o -.eps -.dvi";
   23 my $PSTOIMG  = "pip -o -i pstoimg -antialias -out -.png -quiet -transparent -type png -";
   24 
   25 my $imageFile = shift @ARGV;
   26 
   27 local (*TEXOUT, *IMAGEIN);
   28 my $pid = open2(\*IMAGEIN, \*TEXOUT, "$TEX | $DVIPS | $PSTOIMG") or exit 1;
   29 print TEXOUT HEADER, <STDIN>, FOOTER or exit 2;
   30 close TEXOUT;
   31 open IMAGEOUT, ">", $imageFile or exit 3;
   32 print IMAGEOUT <IMAGEIN> or exit 4;
   33 close IMAGEOUT;
   34 close IMAGEIN;
   35 waitpid $pid, 0;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9