# Error including a .png: Cannot determine size of graphic [duplicate]

This question already has an answer here:

I have a little problem: I am not able to put an image in my document. This is how I start:

\documentclass[a4paper,12pt,titlepage]{report}

\usepackage{fontenc}
\usepackage[italian]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{graphicx}

\begin{document}

.

.

.

\begin{figure}[htbp]

\begin{center}

\includegraphics{mol.png}

\end{center}

\label{fig:uno}

\end{figure}

.

.

.

\end{document}


and this is the error report:

ERROR: LaTeX Error: Cannot determine size of graphic in mol.png (no BoundingBox).

--- TeX said ---

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
...

l.67 \includegraphics{mol.png}


Some months ago I used the same procedure and it worked.

I even tried to reproduce the .dvi file from the .tex file that I wrote some months ago but today doesn't work.

Another question: how can I produce a .pdf file from a .tex file? I forgot it.

I'm working on debian using emacs

-

## marked as duplicate by Papiro, Martin Schröder, Malipivo, Masroor, JubobsAug 15 '14 at 21:58

Welcome to TeX.sx! – Harish Kumar Jan 22 '13 at 15:06
Your picture may be damaged; normally a png picture contains its dimensions. To produce a pdf: pdflatex source.tex, where source.tex is your main file (the one that contains your preamble) – Lionel MANSUY Jan 22 '13 at 15:10
Welcome to TeX.sx! This question is very similar to MikTex error for PNG images when trying to produce DVI and Cannot determine size of graphic. Please take a look at it as the information there might help you. If so, that's great, and we'll probably close this question as a duplicate just to keep the place tidy and to help people find answers quickly. If not, please edit your question here to explain why so that people can better focus their attention to help you. – Martin Schröder Jan 22 '13 at 15:54

If you use the AucTeX-mode with your Emacs, you can switch the output type between pdf and dvi by typing C-c C-t C-p. Then AucTeX uses pdflatex which handles png-files by default, as @David Carlisle mentioned in his answer.

To have pdf output enabled by default with AucTeX, you can put something like this in our .emacs: (setq TeX-PDF-mode t)

To enable it just for the one particular file each time it is loaded, add something like this to the end of your file:

%%% Local Variables:
%%% mode: latex
%%% TeX-PDF-mode: t
%%% End:


I hope this is helpful.

-

If you use the command latex (making dvi) you need to specify the natural size the image natwidth=... natwidth=... (not width= as that tries to scale to that size but still needs the natural size. If you use the command pdflatex (making pdf directly) Then the system can read the file and determine its natural size automatically. In either case it is usually a good idea to omit the extension .png then if different systems understand different image formats they will each pick up the right format.

-