I was wondering what options were available to generate .png based on the kind of input one feeds a graphing calculator.. so
(y^2 + 5x + 3) / ((3x + 3) + 5y + 18)
would return
The only thing I've found so far is texvc in mediawiki, but it seems overkill to get the whole mediawiki for one of it's modules.
The Google Chart API has this function, it takes TeX input and creates an output image.
Another option is jsMath.
There's dvipng
that ships with TeX. It has a lot of parameters to twiddle. That's good if you want such control, but bad if you'd like something simpler to use.
Matplotlib's mathtext engine can turn a subset of TeX into images. See specifically MathtextBackendBitmap for a solution that does not require the other matplotlib backends.
If that doesn't help, matplotlib also has code that calls TeX and dvipng.
Sage could also include some useful code.
An option using Mathematica is:
Export["etc.png",
Rasterize[TraditionalForm[HoldForm[(y^2 + 5 x + 3)/((3 x + 3) + 5 y + 18)]]]]
which produces this image file:
As many people cited, TeX might be the most straightforward path to take there - Searching for python tex yields some possibilities, one of the simpler might be: http://pypi.python.org/pypi/tex/1.5
It is just a wrapper to call Tex as a subprocess, and have a "dvi" file -- you'd still have to run dvipng (which as @JohnCook puts it, comes with TeX) to get your png file.
The drawback is that you have to set up the full TeX tool chain (not a problem on most Linux distributions).
Anotherway would be to get hold of MathMl rendering libraries - but then, you'd have to assemble the MathML markup for yur equation. Thre is a promising Python MathML to SVGmodule here: http://sourceforge.net/projects/svgmath/ That should have less librarie dependencies, and depending on your purposes, SVG might be more suitable than .PNG for equations. Else, ask stackoverflow again to go from .svg to .png in Python :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With