Possible Duplicate:
Compile a latex document into a png image that's as short as possible.
I once found a class on the Internet which allowed to export an latex image to an automatically cropped pdf file. It may even have allowed to automatically to the pdf/png conversion but I am not so sure about that. Basically it worked as
\documentclass{???}
\begin{document}
\[ a+b = c \]
\end{document}
and latex would produce an pdf file which dimensions exactly match the content.