Graphic File Formats


PDFLATEX, when used with graphics or graphicx packages, can correctly compile PNG and JPG files into DVI or PDF, but is not able to handle EPS files. Conversely, the process of compiling with LATEX to DVI and converting to PS and eventually PDF does support EPS, but does not support PNG and JPG.

A lot of users want to create PDF documents, but also want to use the excellent Pstricks package to create PostScript® graphics, or they want to use the PostScript® output of mathematical and scientific software like Mathematica, Maple or MuPAD. These LATEX users have to compile first in PostScript®, even if they want to create PDF documents, because these programs produce PostScript® code which cannot be managed by PDFLATEX. However, it is not so hard as it may sound, because Kile will help.

Graphics Conversion

To overcome this frustrating loop, when you want to include both PostScript® code and PNG or JPG files, you have a number of workarounds:

  • If you need a file in PS format, but have JPG or PNG graphics, you can also simply use PDFLATEX with DVI output first, and then run dvips to create the PS file. You see that PDFLATEX is a very good choice, if your source contains no PostScript® code at all.

  • You can convert EPS files to PNG or other formats with utilities as the Gimp or ImageMagick and use PDFLATEX.

  • A preferred way is to convert EPS graphics to PDF graphics with epstopdf, which comes with every TEX distribution and then use PDFLATEX. It produces high quality graphics, and you can even control the result with some of the following options:


    Even better: if your system allows shell-escape, conversion can be done on the fly. All you have to do is to include the epstopdf package, which is part of all TEX distributions, with the command \usepackage{epstopdf}. Assuming that your code is:


    When you call PDFLATEX with option --shell-escape, graphics test.eps is automatically converted into test.pdf.

    This conversion will take place each time you run PDFLATEX. If your graphics command is given implicitly:


    epstopdf checks whether test.pdf is already available, so that the conversion step can be skipped.

  • You can convert the other way around, and use LATEX and PS-PDF conversion. This is not always a good idea, since EPS encapsulation of JPG or PNG can yield larger files, that in turn yield unnecessarily large documents. This is however highly dependent on the graphic utility that you use, since EPS can encapsulate other graphics, but not all applications support this perfectly. Some might actually try to build your JPG image with vectors and various scripting, which will result in gigantic files. Conversion of all graphics formats to EPS can be done by ImageMagick. Another simple program that does this process correctly is jpg2ps.

  • You can also use an automatic conversion. All graphics files are converted on the fly to EPS, and inserted into the PS document. This is a comfortable way, but you have to set up your system properly. This is discussed in the section EPS Graphics.

Use the right File for the right Graphic

  • EPS is sort of a graphic vector scripting language, describing all the lines and dots the graphic is made of; it looks good even when magnified beyond its default size, and suits best diagrams and vectorial graphics natively produced in EPS, which look very clear and sharp while maintaining a very small byte size.

  • PNG (or the deprecated GIF) is a non-lossy file format, with good compression and quality. It is very good for diagrams, scans of drawings, or anything whose sharpness you do want to retain. It is sometimes overkill when used for photos.

  • JPG is a lossy format, that compresses files better than PNG at the price of some loss in the picture detail. This is usually irrelevant for photos, but may cause bad quality for diagrams, drawings, and may make some thin lines disappear outright; in those cases use EPS or PNG.

But always remember: garbage in, garbage out! No conversion will make a bad picture good.