[Tex/LaTex] MikTex error for PNG images when trying to produce DVI

dvierrorsgraphicsmiktexpng

I have a tex file with \includegraphic elements for some PNG images.
I use MikTeX on Windows and the PDF is fine.

Now, I need a DVI so I tried using: \pdfoutput=0
This creates a DVI, but only after I remove all the PNG images…
Otherwise I get errors like:

! LaTeX Error: Cannot determine size of graphic in math-box-plot.png (no BoundingBox).

Best Answer

TeX is text based, it cannot determine the size of PNG image itself by default.

A quick solution:

\usepackage{bmpsize}

And use

\usepackage[dvipdfmx]{graphicx}

It is better to use extractbb (also named ebb, xbb) program to produce .bb or .xbb file for LaTeX. Use this command in 'Command Prompt':

for %i in (*.png) do xbb %i

(or for %i in (*.png) do extractbb -x %i, I'm not sure about MiKTeX.)

And use

\usepackage[dvipdfmx]{graphicx}

(I use TeX Live, only dvipdfmx supports png images. But MiKTeX seems different, I can't remember well.)