40

I am getting the following error while compiling my Latex File :

! LaTeX Error: Cannot determine size of graphic in tree.jpg (no BoundingBox).

Why do I get this error ? What has this to do with an .eps file ?

In fact, I could compile it fine with MacTex on my machine. But when I submit it online to a scientific journal for publication, it compiles it on the server and sends me the resultant PDF which has all these errors that prevent it from compiling.

I am using the following syntax for including the images :

\begin{figure}[!h]
    \begin{center}
        \scalebox{0.45}{
            \includegraphics{tree.jpg}}
    \end{center}
            \caption{\small A sample}
            \label{tree}
\end{figure}

What should I do ? Could it be that their server is using an old compiler ?

UPDATE : It finally worked. I converted the first image to PDF and the compilation happened perfectly. I guess it used the bounding box value from that PDF and applied it to all images.

8
  • 1
    Are you using pdflatex? Cause latex only supports vector graphics (read: eps)
    – Stephan202
    Apr 8, 2009 at 21:36
  • 1
    For what it's worth, JPG is quite possibly the worst image format to use when you're going to print something (because of the quality degradation). In Latex EPS is best, PDF is a close second.
    – David Z
    Apr 8, 2009 at 21:46
  • 1
    @David: EPS and PDF are essentially equivalent when it comes to image quality. It just depends whether you're using LaTeX or pdfLaTeX as to which you'd choose. Apr 9, 2009 at 2:14
  • 2
    Should we migrate this (and other tex questions) to tex.stackexchange.com?
    – Tom
    Jan 6, 2011 at 13:54
  • 4
    Duplicate of: tex.stackexchange.com/questions/98679/… Aug 13, 2013 at 0:10

7 Answers 7

26

To include png and jpg, you need to specify the Bounding Box explicitly.

\includegraphics[bb=0 0 1280 960]{images/some_image.png}

Where 1280 and 960 are respectively width and height.

2
  • 3
    that would make the document terribly fragile to included image size changes, wouldn't it ?
    – PypeBros
    Mar 14, 2013 at 10:13
  • 2
    @sylvainulg : you are right
    – h3xStream
    Mar 14, 2013 at 23:59
22

I've had the same problems including jpegs in LaTeX. The engine isn't really built to gather all the necessary size and scale information from JPGs. It is often better to take the JPEG and convert it into a PDF (on a mac) or EPS (on a PC). GraphicsConvertor on a mac will do that for you easily. Whereas a PDF includes DPI and size, a JPEG has only a size in terms of pixels.

( I know this is not the answer you wanted, but it's probably better to give them EPS/PDF that they can use than to worry about what happens when they try to scale your JPG).

11
  • Thanks. Great help. But then why is it working on my machine ? How is it getting the bounding box values ?
    – euphoria83
    Apr 8, 2009 at 21:38
  • MacTex seems to be more robust than other Tex distributions that I've seen. After working with too many academic publishers I've realized that I can never find something as old and incompatible as whatever they're using, so I just create EPS or PDFs.
    – Uri
    Apr 8, 2009 at 21:41
  • By the way, if you draw diagrams take a look at OmniGraffle. One of the best reasons to use a Mac
    – Uri
    Apr 8, 2009 at 21:44
  • Yeah, its surprising how the interface for CS journals are so out-dated. How do I convert to PDF format ? Is GraphicsConvertor a software provided with the OS ? I could not find it here and on the internet.
    – euphoria83
    Apr 8, 2009 at 21:56
  • 1
    @euphoria: Which journal are you publishing to? A lot of the ACM journals and conferences actually take word files, which is even worse.
    – Uri
    Apr 8, 2009 at 22:01
12

Using .jpg files do not forget about compiling directly to .pdf (pdflatex) and use: graphicx package with pdftex option (\usepackage[pdftex]{graphicx}).

3
  • 1
    Compiling into pdf works, thanks. Feb 3, 2012 at 13:40
  • 1
    N.B.: But it's not always the best solution. Working with DVI is often faster and compatible with more packages. So sometimes, it is worth converting an image into a PDF. Mar 4, 2012 at 1:59
  • 1
    and when one comes from a regular latex compile and want to switch to pdflatex, that [pdftex] is likely to be missing in the {graphicx} line.
    – PypeBros
    Mar 14, 2013 at 10:31
7

If you have Gimp, I saw that exporting the image in .eps format would do the job.

4

I use MacTex, and my editor is TexShop. It probably has to do with what compiler you are using. When I use pdftex, the command:

\includegraphics[height=60mm, width=100mm]{number2.png}

works fine, but when I use "Tex and Ghostscript", I get the same error as you, about not being able to get the size information. Use pdftex.

Incidentally, you can change this in TexShop from the "Typeset" menu.

Hope this helps.

2
  • yeah. but i can't change the engine on the server. ;-)
    – euphoria83
    Apr 8, 2009 at 22:01
  • Yea, I had the same problem when I tried using this. I eventually just decided to let the file contain everything.
    – Uri
    Apr 8, 2009 at 22:02
3

On a Mac (pdftex) I managed to include a png file simply with

\includegraphics[width=1.2\textwidth]{filename.png}

. But in order for that to work I had to comment out the following 2 packages:

%\usepackage[dvips]{epsfig}

%\usepackage[dvips]{graphicx}

...and simply use package graphicx:

\usepackage{graphicx}

It seems [dvips] is problematic when used with pdftex.

1
  • removing this [dvips] is working for me, i hate this [dvips] spend my whole days Nov 25, 2022 at 2:59
0

I had the same problem, caused by a clash between the graphicx package and an inclusion of the epsfig package that survived the ages...

Please check that there is no inclusion of epsfig, it is deprecated.

Not the answer you're looking for? Browse other questions tagged or ask your own question.