How to export a equation as a image without background?

Use convert from from ImageMagick:

pdflatex formula.tex
convert -density 300 formula.pdf -quality 90 formula.png

Here is the resulting PNG file:

enter image description here

This solutions is from TeX to image over command line, which you should see as this will allow you to specify the formula on the command line.


The following works for me:

  1. Compile to dvi using latex (not pdflatex!).

    By the way, you have a typo in your example: should be P\left(H_h|E_e\right)=\frac{P\left(E_e|H_h\right)P\left(H_h\right)}{P\left(E_e\right)}

  2. Use dvipng:

    dvipng -bg transparent -o myfile.png myfile.dvi
    

I need this to generate equation images to a presentation.

I use an online latex equation editor that has the option to download it as .gif.