I'm trying to include graphics in my Latex-file, which I compiled with latex+dvipdf on OS X. Latex however returns this error: "Cannot determine size of graphic"

My graphic is exported from PowerPoint, so I have tried both .pdf and .png. I get the same errors for both.

Sample code that doesn't work:


If I have to manually set some measurements of the image, please tell me how I can find out those measurements. I need the image to take up about 80% of text width and be centered. Thanks.


The DVI producing latex doesn't support reading the size of PNG, JPG or PDF images. You need to use pdflatex for this. Actually latex is pdflatex in DVI mode in modern distributions, but it can read the sizes only in PDF mode for some reason. You are however able to state the natural size of the images using natwidth and natheight which will make latex compile without error. The produced DVI file will only link to the PDF and the DVI-to-PDF converter will need to include it in the final PDF. AFAIK dvpdf doesn't support this but dvipdfm does.




Compile with either

pdflatex <file base>


latex <file base>
dvipdfm <file base>
|improve this answer|||||
  • 3
    For dvipdfm(x), one should use dvipdfm or dvipdfmx option of graphicx pacakge, and use extractbb (ebb, xbb) program to produce .bb or .xbb file. bmpsize package can also used to replace extractbb. – Leo Liu May 8 '11 at 15:15
  • 6
    Thank you for the solution provided. I simply added \usepackage[dvipdfm]{graphicx} \usepackage{bmpsize} to my file, and it worked perfectly ! No need to spend time to manually set the bounding box with the time-consuming trial-and-errors method (what I did until this day). – user41288 Nov 19 '13 at 15:17
  • I used this solution for a png-figure with latex, dvipdfmx and graphicx-package, which worked for me without doing anything additional (2013 TeX Live) – Bernhard Jul 3 '14 at 12:09
  • 3
    user41288 solution is great, but there is a typo in the provided code (dvipdfmx). The following one worked for me: \usepackage[dvipdfmx]{graphicx} \usepackage{bmpsize} – zeroos May 12 '15 at 20:56
  • Just to add: specificying natwidth and natheight also solved a problem I had with jpgs having incorrect bounding boxes (so the tex file compiles, but the image ends up misplaced). – Matthew Leingang Nov 5 '15 at 1:10

A non-Latex solution

A very fast solution is to convert the png file into eps format. It can be done easily using graphic software, for instance Inkscape.

So, you only need to open the file in Inkscape and then SaveAs and select eps format.

Now change the extension in the tex file from



|improve this answer|||||
  • 6
    excellent and simple solution. I'd add using command-line convert tiger.jpg eps2:tiger.eps for another easy & easily scriptable way of converting images, as proposed in this answer: stackoverflow.com/a/14220700/3551299 – tlegutko May 15 '17 at 21:52
  • 1
    Nice! I used gimp to convert from .png to .eps gimp.org – wordsforthewise Jul 24 '17 at 21:48
  • Perfect! I used gimp! – Sergio Sep 30 '17 at 5:01
  • png also doesnt work – Tessaracter Aug 12 '18 at 16:37
  • 1
    Unfortunately EPS files are about ten times the size of PNG files. – U. Windl Mar 3 '19 at 22:27

I got this error with a pdf file which contained dots in the filename. Removing the dots (except the .pdf, of course) fixed the issue.

|improve this answer|||||
  • 2
    yep, here, too. Is there an open bug report about it anywhere? – Frederick Nord Apr 13 '18 at 14:02
  • 1
    how true it is! very unlikely widely used programs like gimp or inkscape randomly produce wrong images what (Xe)LaTeX can not process. indeed the dot was the reason. – deeenes Oct 15 '18 at 3:43
  • 1
    This is still an issue today (2019-02-20) with the latest updated MikTeX on Windows. My document had been building fine with an outdated MikTeX install, but I started getting this error after updating and came across this answer while trying to resolve the problem. Turns out renaming the image files to not have dots in the names fixed it. – Herohtar Feb 20 '19 at 19:18
  • 3
    Confirming this is still an issue (MacTex 2018); switching from dots to underscores in the filename fixed the issue mentioned in the OP. – Ollin Boer Bohan Mar 3 '19 at 19:46

I saw this issue with a jpeg file. By changing its extension from .JPG to .jpg (yes, just capital to lower) the error went away.

$ pdflatex --version
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian) restricted \write18 enabled.
|improve this answer|||||