2007-04-22

texpng.py

I wrote a python script called texpng.py which converts a block of LaTeX code to a png picture file. Charles's tex2png.pl is fine, but it makes some errors on my machine. So I just wanted to DIY my own.

Download here.

Usage: texpng.py [options]

Options:
  -h, --help            show this help message and exit
  -o FILE, --output-file=FILE
                        Write the generated PNG to FILE.
  -b BG, --background=BG
                        Specify the background color.
                        Eg. 'rgb 1.0 1.0 1.0', which is the 
                        default.
  -f FG, --foreground=FG
                        Specify the foreground color.  
                        Eg. 'rgb 0.0 0.0 0.0', which is the
                        default.
  -p, --opaque          Tell whether the background should be not 
                        transparent.
  -n, --negtive         Do the same things as "-b 'rgb 0.0 0.0 0.0'
                        -f 'rgb 1.0 1.0 1.0'".  This will override 
                        "-f" and "-b" options.
  -v, --verbose         Output lots of informations.

Show one example. The TeX code is

\[
y(x) = \int_{x_0}^x \left[\cos\frac{i\omega t}{x_0^2}+
\sin(i\omega t + \phi_0)\right]\textrm{d}t
\]

And the output is

FIX: Added --dpi option, which enables users to adjust the font size. See --help information for detail.

0 doomers: