# How to create fixed size image From a tex file



## sw2wolf (Jan 13, 2018)

Suppose a.tex contains a few Math formulas.  How can i  produce a 500x500 png/jpg file From a.tex?

www.latex2png.com produces unpredictable size png Even If setting the resolution.

Sincerely!


----------



## Birdy (Jan 13, 2018)

How about these: see here and here? ( found through this  )


----------



## Sensucht94 (Jan 13, 2018)

Hi,

Install (if  you haven't yet):

print/texinfo

print/tex-dvipsk

misc/latex-mk

graphics/ImageMagick
Then:


```
% texi2dvi -o foo.dvi foo.tex
% dvips flux.dvi
% convert -adaptive-resize 500x500 foo.ps foo.png
```

You could also use `convert`'s `-density` switch to render the postscript file, see convert(1)


----------



## sw2wolf (Jan 14, 2018)

```
$cat log.tex
%pdflatex -shell-escape log.tex
\documentclass[14pt]{standalone}
\pagestyle{empty}
\usepackage{graphicx}
\immediate\write18{pdflatex log.tex}
\immediate\write18{convert -density 200 -adaptive-resize 500x500 log.pdf log.png}
\usepackage{amsmath}
\begin{document}
\begin{minipage}{0.75\textwidth}
\centering
%\includegraphics[width=2in]{figure/4/OriginalStereo.jpg}
Logarithm Formula
\begin{align*}
1&.\log_b^{log_b^{a}}=a,a^{\frac{m}{n}}=\sqrt[n]{a^m}\\
2&.\log_c^{(a\times{b})}=\log_c^{a}+\log_c^{b}\\
3&.\log_c^{\frac{a}{b}}=\log_c^{a}-\log_c^{b}\\
4&.\log_a^{b}=\frac{log_c^{a}}{log_c^{b}}\\
=>\\
5&.\log_a^b=\frac{1}{\log_b^a}\\
6&.\log_\emph{a}^b\times\log_b^c\times\log_c^\emph{d}=\log_a^d\\
7&.\log_{a^m}^{b^n}=\frac{n}{m}\log_a^b
\end{align*}
\end{minipage}
\end{document}
```

Just by running 
	
	



```
pdflatex -shell-escape log.tex
```
 i get both log.pdf and log.png simultaneously.

Although it is NOT accurately 500x500, it is acceptable !

Thanks for all your big help !


----------

