Exports an image by compiling a string of LaTeX code and then converting the output using gs and convert (from the ImageMagick package). The script input can consist of just the LaTeX body or the full document with headers (one page documents only).
tex2image '$ f_1(x) := 3x^2-2y $' f1.png
Produces:
tex2image -X 300 -Y 300 --pagecolor .3,.3,.3 --color 1,0,0 '$f_2(x):=e^{-x^2}$' f2.png
Produces: