5

I have a need for producing PNG output from latex. My current method - and the only one I am aware of - is to latex and then dvipng. In order to do this, I need to include an eps of any graphics I wish to import because latex won't have it any other way (right?). Is there any way to delay the import of graphics until I get to the dvipng stage so that I could use, say, a png resource instead of an eps to get my final product?

5
  • Are you on Windows or Linux?
    – Jake
    Commented Dec 15, 2013 at 21:51
  • Linux, Ubuntu Server 13.04 specifically
    – mrKelley
    Commented Dec 15, 2013 at 21:57
  • Then I would just use pdflatex (which supports PNG directly) to create a PDF, and then convert that PDF to PNG using ImageMagick (command line convert <name>.pdf -density 300 <name>.png, for instance).
    – Jake
    Commented Dec 15, 2013 at 22:01
  • The dvi file never includes the actual image (and latex doesn't read it either) you only need a file name, and the type of image files that the graphics package accepts depends only on the driver so if you are using dvipng and it accepts png and not eps you should be specifying the png file to latex. Commented Dec 15, 2013 at 22:02
  • see page 4 of the dvipng manual (texdoc dvipng) which shows how to specify png image files to latex Commented Dec 15, 2013 at 22:07

1 Answer 1

5

LaTeX has no preference between EPS or PNG (it doesn't understand either). Also a dvi file always works the way you suggest the dvi file just references the external image by name, it need not exist at the time latex is run, it just needs to be there when the dvi driver is used.

You do need to tell LaTeX how big the image is, as explained in the manuals for the graphics package, or the dvipng driver.

\includegraphics[bb=0 0 300 400]{imagename.png}

for a 300 by 400 pixel image at default (72DPI) size.

3
  • That worked. I was never able to do this before because I wasn't specifying the bounding box. With pdflatex, I never had to specify bb, so I didn't even know about it.
    – mrKelley
    Commented Dec 15, 2013 at 22:46
  • 1
    @mrKelley graphics package should have given you a helpful message saying it didn't know the size:-) pdflatex essentially is its own driver so it does need the image files to be there (and it can read them to import them so knows the size, just as dvips/dvipng do) Commented Dec 15, 2013 at 23:00
  • yeah, it did .___.
    – mrKelley
    Commented Dec 16, 2013 at 1:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .