#!/usr/bin/perl # PS/TeX/TeX-eqn to GIF/PNG/BMP converter by Kumagai Masaaki # PS/TeX/TeX-eqn to GIF/PNG/BMP 熊谷正朗 (google://熊谷正朗/) # frontend script # # 本プログラムの使用、配布、改良は自由ですが、それを行う方の # 責任にて、お願いします。 (05/01/08) @INC=(".",@INC); require 'psimglib.pl'; if($ARGV[0] eq "-d"){ $psimglibdebug=1; shift; $tmpbase="debug_" }else{ $tmpbase=$$; } $cmd=$0; $cmd=~s/^(.*\/)([^\/]*)$/\2/; $0=~/^([^2]+)2([^2]+)$/; # print STDERR "$1 to $2\n"; $srctype=$1; $desttype=$2; # 出力選択 %type=SelectOutputFormat($desttype); $desttype=$type{'type'}; $destext=$type{'ext'}; if($srctype=~/tex/){ if($ARGV[1] eq '') { print STDERR "\n$cmd: TeX source string to $desttype image file\n\n"; print STDERR " usage $cmd ( )\n"; print STDERR " : 'color name' or '#RRGGBB'\n"; print STDERR "\n example: $cmd '",'\LaTeX'," 'test.$destext 10 red\n\n"; exit(1); } %r=tex2img_update(@ARGV); } elsif($srctype=~/ps/){ if($ARGV[1] eq '') { print STDERR "\n$cmd: EPS file to $desttype image file\n\n"; print STDERR " usage $cmd ( "; print STDERR " )\n"; print STDERR " : in '%d'(pixel) 'x%f'(mag)\n"; print STDERR " : 'color name' or '#RRGGBB'\n"; print STDERR "\n example: $cmd test.eps test.$destext 100\n"; print STDERR " $cmd test.eps test.$destext x2\n"; print STDERR " $cmd test.eps test.$destext 0 200 red\n\n"; exit(1); } %r=ps2img_update(@ARGV); } elsif($srctype=~/eqn/){ if($ARGV[1] eq '') { print STDERR "\n$cmd: TeX equation to $desttype image file\n\n"; print STDERR " usage $cmd ( )\n"; print STDERR " : 'color name' or '#RRGGBB'\n"; print STDERR "\n example: $cmd '",'y=f(x)',"' test.$destext 10 red\n\n"; exit(1); } $ARGV[0]='\def\vect#1{\mbox{\boldmath$#1$}}\begin{eqnarray}'.$ARGV[0].'\nonumber\end{eqnarray}'; %r=tex2img_update(@ARGV); } else { print STDERR "ps2img: ln -s ps2img [tex/ps/eqn]2[gif/png/bmp]\n"; exit(1); } print STDERR "size: ".$r{'w'}.'x'.$r{'h'}."\n";