37

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.

Mr Lister
  • 42,557
  • 14
  • 95
  • 136
euphoria83
  • 13,314
  • 16
  • 58
  • 70
  • 1
    Are you using pdflatex? Cause latex only supports vector graphics (read: eps) – Stephan202 Apr 08 '09 at 21:36
  • I don't know the engine they are using on the server. My machine has MacTex and it is able to compile it. – euphoria83 Apr 08 '09 at 21:40
  • Ah, yes. s/you/they/. Perhaps you should contact the journal and ask them about the specifics of their latex implementation. – Stephan202 Apr 08 '09 at 21:43
  • 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 08 '09 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. – Will Robertson Apr 09 '09 at 02:14
  • 2
    Should we migrate this (and other tex questions) to http://tex.stackexchange.com? – Tom Jan 06 '11 at 13:54
  • @euphoria83: I flagged the post for moderator attention. Perhaps you can do that too? If we don't hear anything I'll post something on meta about migrating the questions from this tag. – Tom Jan 06 '11 at 15:21
  • 4
    Duplicate of: http://tex.stackexchange.com/questions/98679/latex-error-cannot-determine-size-of-graphic-in-title-png-no-boundingbox – Dave Jarvis Aug 13 '13 at 00:10

7 Answers7

27

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.

h3xStream
  • 5,555
  • 2
  • 38
  • 50
21

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).

Uri
  • 84,589
  • 46
  • 214
  • 312
  • Thanks. Great help. But then why is it working on my machine ? How is it getting the bounding box values ? – euphoria83 Apr 08 '09 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 08 '09 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 08 '09 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 08 '09 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 08 '09 at 22:01
  • Even this journal takes word. I guess that why they don't care much about having an up-to-date latex engine on the server. But still, what's GraphicsConvertor? Is that a software ? – euphoria83 Apr 08 '09 at 22:03
  • Yea, it's a really good conversion software for the mac. Costs a lot, but you could use the demo for a while. http://www.lemkesoft.com/ I use it for all my screenshot and conversion needs. – Uri Apr 08 '09 at 22:05
  • Hey Uri. It worked. Thanx very much. :-) – euphoria83 Apr 08 '09 at 22:30
  • Enjoy. Congratulations on the paper ! I've only done conferences so far. – Uri Apr 08 '09 at 22:43
  • you work on really cool stuff. API documentation is always a big pain. I applied to CMU too. But Luis Von Ahn couldn't help me get in. I had worked on CAPTCHA before. – euphoria83 Apr 08 '09 at 23:00
  • @euphoria83: I think Luis has got his hands full with so many students and people working for him. And this year CMU's been feeling the crunch so the number of students it can support has been lower. – Uri Apr 08 '09 at 23:09
  • IT was a fun topic (took me a while to get to it), it's a pity I'll never follow up on it ever again as I'm going to the industry. I hope I can at least get people to use my eMoose tool. – Uri Apr 08 '09 at 23:10
11

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

kuszi
  • 2,059
  • 29
  • 36
7

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

balaur
  • 96
  • 1
  • 4
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.

Tom
  • 19,598
  • 6
  • 36
  • 44
2

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.

blue scorpion
  • 277
  • 1
  • 9
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.

Tommy
  • 579
  • 7
  • 21